mirror of
https://github.com/metosin/reitit.git
synced 2025-12-16 16:01:11 +00:00
Clean re-frame example initialization
This commit is contained in:
parent
208eeeb5c5
commit
dea8894610
3 changed files with 9 additions and 11 deletions
|
|
@ -33,7 +33,7 @@
|
|||
{:builds
|
||||
[{:id "dev"
|
||||
:source-paths ["src/cljs"]
|
||||
:figwheel {:on-jsload "frontend-re-frame.core/mount-root"}
|
||||
:figwheel true
|
||||
:compiler {:main frontend-re-frame.core
|
||||
:output-to "resources/public/js/compiled/app.js"
|
||||
:output-dir "resources/public/js/compiled/out"
|
||||
|
|
|
|||
|
|
@ -2,12 +2,9 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="js/compiled/app.js"></script>
|
||||
<script>frontend_re_frame.core.init();</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@
|
|||
|
||||
(re-frame/reg-event-db
|
||||
::initialize-db
|
||||
(fn [_ _]
|
||||
{:current-route nil}))
|
||||
(fn [db _]
|
||||
(if db
|
||||
db
|
||||
{:current-route nil})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::navigate
|
||||
|
|
@ -141,13 +143,12 @@
|
|||
(enable-console-print!)
|
||||
(println "dev mode")))
|
||||
|
||||
(defn mount-root []
|
||||
(defn init []
|
||||
(re-frame/clear-subscription-cache!)
|
||||
(re-frame/dispatch-sync [::initialize-db])
|
||||
(dev-setup)
|
||||
(init-routes!) ;; Reset routes on figwheel reload
|
||||
(reagent/render [router-component {:router router}]
|
||||
(.getElementById js/document "app")))
|
||||
|
||||
(defn ^:export init []
|
||||
(re-frame/dispatch-sync [::initialize-db])
|
||||
(dev-setup)
|
||||
(mount-root))
|
||||
(init)
|
||||
|
|
|
|||
Loading…
Reference in a new issue