0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 15:09:10 -05:00

Fix initialization order of the application.

This commit is contained in:
Andrey Antukh 2015-12-17 17:01:52 +02:00
parent b317ee4904
commit 0fc77d0283
3 changed files with 14 additions and 9 deletions

View file

@ -1,7 +1,7 @@
(ns uxbox.core (ns uxbox.core
(:require [beicon.core :as rx] (:require [beicon.core :as rx]
[uxbox.router]
[uxbox.state :as s] [uxbox.state :as s]
[uxbox.router :as r]
[uxbox.rstore :as rs] [uxbox.rstore :as rs]
[uxbox.ui :as ui] [uxbox.ui :as ui]
[uxbox.data.load :as dl])) [uxbox.data.load :as dl]))
@ -10,7 +10,8 @@
(defonce +setup+ (defonce +setup+
(do (do
(println "bootstrap")
(r/init)
(ui/init) (ui/init)
(rs/emit! (dl/load-data)) (rs/emit! (dl/load-data))
(rx/on-value s/stream #(dl/persist-state %)) (rx/on-value s/stream #(dl/persist-state %))))
1))

View file

@ -11,7 +11,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Events ;; Events
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn update-location (defn update-location
[{:keys [handler route-params] :as params}] [{:keys [handler route-params] :as params}]
(reify (reify
@ -61,10 +60,14 @@
["colors" :dashboard/colors]]] ["colors" :dashboard/colors]]]
["workspace/" [[page-route :workspace/page]]]]]) ["workspace/" [[page-route :workspace/page]]]]])
(defonce +router+ (def ^:static ^:private +router+ nil)
(defn init
[]
(let [opts {:on-navigate #(rs/emit! (update-location %)) (let [opts {:on-navigate #(rs/emit! (update-location %))
:default-location {:handler :dashboard/projects}}] :default-location {:handler :dashboard/projects}}
(bidi.router/start-router! routes opts))) router (bidi.router/start-router! routes opts)]
(set! +router+ router)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public Api ;; Public Api

View file

@ -22,6 +22,7 @@
(defn app-render (defn app-render
[own] [own]
(let [{:keys [location location-params] :as state} (rum/react state)] (let [{:keys [location location-params] :as state} (rum/react state)]
(println "app-render" location state)
(case location (case location
:auth/login (ui.users/login) :auth/login (ui.users/login)
:dashboard/projects (ui.dashboard.projects/projects) :dashboard/projects (ui.dashboard.projects/projects)
@ -42,5 +43,5 @@
[] []
(let [app-dom (gdom/getElement "app") (let [app-dom (gdom/getElement "app")
lb-dom (gdom/getElement "lightbox")] lb-dom (gdom/getElement "lightbox")]
(util/mount (app) app-dom) (rum/mount (app) app-dom)
(util/mount (ui.lb/lightbox) lb-dom))) (rum/mount (ui.lb/lightbox) lb-dom)))