From 0fc77d0283276bd8bff83392c9d72a40302c4c11 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 17 Dec 2015 17:01:52 +0200 Subject: [PATCH] Fix initialization order of the application. --- frontend/uxbox/core.cljs | 7 ++++--- frontend/uxbox/router.cljs | 11 +++++++---- frontend/uxbox/ui.cljs | 5 +++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/frontend/uxbox/core.cljs b/frontend/uxbox/core.cljs index fdf68efc76..eb1ee71bc5 100644 --- a/frontend/uxbox/core.cljs +++ b/frontend/uxbox/core.cljs @@ -1,7 +1,7 @@ (ns uxbox.core (:require [beicon.core :as rx] - [uxbox.router] [uxbox.state :as s] + [uxbox.router :as r] [uxbox.rstore :as rs] [uxbox.ui :as ui] [uxbox.data.load :as dl])) @@ -10,7 +10,8 @@ (defonce +setup+ (do + (println "bootstrap") + (r/init) (ui/init) (rs/emit! (dl/load-data)) - (rx/on-value s/stream #(dl/persist-state %)) - 1)) + (rx/on-value s/stream #(dl/persist-state %)))) diff --git a/frontend/uxbox/router.cljs b/frontend/uxbox/router.cljs index 427c8cd08e..7cd88ed1b6 100644 --- a/frontend/uxbox/router.cljs +++ b/frontend/uxbox/router.cljs @@ -11,7 +11,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Events ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (defn update-location [{:keys [handler route-params] :as params}] (reify @@ -61,10 +60,14 @@ ["colors" :dashboard/colors]]] ["workspace/" [[page-route :workspace/page]]]]]) -(defonce +router+ +(def ^:static ^:private +router+ nil) + +(defn init + [] (let [opts {:on-navigate #(rs/emit! (update-location %)) - :default-location {:handler :dashboard/projects}}] - (bidi.router/start-router! routes opts))) + :default-location {:handler :dashboard/projects}} + router (bidi.router/start-router! routes opts)] + (set! +router+ router))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Public Api diff --git a/frontend/uxbox/ui.cljs b/frontend/uxbox/ui.cljs index 00fd827be2..a1492beefe 100644 --- a/frontend/uxbox/ui.cljs +++ b/frontend/uxbox/ui.cljs @@ -22,6 +22,7 @@ (defn app-render [own] (let [{:keys [location location-params] :as state} (rum/react state)] + (println "app-render" location state) (case location :auth/login (ui.users/login) :dashboard/projects (ui.dashboard.projects/projects) @@ -42,5 +43,5 @@ [] (let [app-dom (gdom/getElement "app") lb-dom (gdom/getElement "lightbox")] - (util/mount (app) app-dom) - (util/mount (ui.lb/lightbox) lb-dom))) + (rum/mount (app) app-dom) + (rum/mount (ui.lb/lightbox) lb-dom)))