Clean re-frame example initialization

This commit is contained in:
Juho Teperi 2020-09-23 13:12:00 +03:00
parent 208eeeb5c5
commit dea8894610
3 changed files with 9 additions and 11 deletions

View file

@ -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"

View file

@ -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>

View file

@ -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)