-
-
Save 6ewis/43b7c96a7f9514f6c2ebe8a358c5cd3f to your computer and use it in GitHub Desktop.
note: look at line 6 and line 32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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