Skip to content

Instantly share code, notes, and snippets.

@6ewis

6ewis/core.cljs Secret

Created May 14, 2016 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 6ewis/43b7c96a7f9514f6c2ebe8a358c5cd3f to your computer and use it in GitHub Desktop.
Save 6ewis/43b7c96a7f9514f6c2ebe8a358c5cd3f to your computer and use it in GitHub Desktop.
note: look at line 6 and line 32
(ns myproject.core
(:require [reagent.core :as reagent :refer [atom]]
[reagent.session :as session]
[secretary.core :as secretary :include-macros true]
[accountant.core :as accountant]
[myproject.core.playground :refer [play]]));; i added this line
;; -------------------------
;; Views
(defn home-page []
[:div [:h2 "Welcome to myproject"]
[:div [:a {:href "/about"} "go to about page"]]])
(defn about-page []
[:div [:h2 "About myproject"]
[:div [:a {:href "/"} "go to the home page Lewis"]]])
(defn current-page []
[:div [(session/get :current-page)]])
;; -------------------------
;; Routes
(secretary/defroute "/" []
(session/put! :current-page #'home-page))
(secretary/defroute "/about" []
(session/put! :current-page #'about-page))
(secretary/defroute "/playground" []
(session/put! :current-page #'play)) ;;
;; -------------------------
;; Initialize app
(defn mount-root []
(reagent/render [current-page] (.getElementById js/document "app")))
(defn init! []
(accountant/configure-navigation!
{:nav-handler
(fn [path]
(secretary/dispatch! path))
:path-exists?
(fn [path]
(secretary/locate-route path))})
(accountant/dispatch-current!)
(mount-root))
(ns myproject.core.playground)
;;playground
(defn play []
[:div [:h2 "Welcome to my playground"]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment