2015-06-18 12:35:50 -05:00
|
|
|
(ns uxbox.core
|
2015-12-17 09:43:58 -05:00
|
|
|
(:require [beicon.core :as rx]
|
2015-12-23 08:44:03 -05:00
|
|
|
[cats.labs.lens :as l]
|
|
|
|
[uxbox.state :as st]
|
2015-12-22 17:42:24 -05:00
|
|
|
[uxbox.router :as rt]
|
2015-12-14 07:17:18 -05:00
|
|
|
[uxbox.rstore :as rs]
|
2015-12-17 09:43:58 -05:00
|
|
|
[uxbox.ui :as ui]
|
|
|
|
[uxbox.data.load :as dl]))
|
2015-06-18 12:35:50 -05:00
|
|
|
|
|
|
|
(enable-console-print!)
|
|
|
|
|
2015-12-23 08:44:03 -05:00
|
|
|
(defn main
|
|
|
|
"Initialize the storage subsystem."
|
|
|
|
[]
|
|
|
|
(let [lens (l/select-keys [:pages-by-id
|
2015-12-29 08:51:47 -05:00
|
|
|
:shapes-by-id
|
2015-12-24 12:32:10 -05:00
|
|
|
:colors-by-id
|
2015-12-23 08:44:03 -05:00
|
|
|
:projects-by-id])
|
|
|
|
stream (->> (l/focus-atom lens st/state)
|
|
|
|
(rx/from-atom)
|
2015-12-28 13:06:26 -05:00
|
|
|
(rx/debounce 1000)
|
2015-12-23 08:44:03 -05:00
|
|
|
(rx/tap #(println "[save]")))]
|
|
|
|
(rx/on-value stream #(dl/persist-state %))))
|
|
|
|
|
2015-12-14 16:57:47 -05:00
|
|
|
(defonce +setup+
|
2015-12-14 07:17:18 -05:00
|
|
|
(do
|
2015-12-17 10:01:52 -05:00
|
|
|
(println "bootstrap")
|
2015-12-22 17:42:24 -05:00
|
|
|
|
2015-12-23 08:44:03 -05:00
|
|
|
(st/init)
|
2015-12-22 17:42:24 -05:00
|
|
|
(rt/init)
|
2015-12-17 05:51:36 -05:00
|
|
|
(ui/init)
|
2015-12-22 17:42:24 -05:00
|
|
|
|
2015-12-14 16:57:47 -05:00
|
|
|
(rs/emit! (dl/load-data))
|
2015-12-23 08:44:03 -05:00
|
|
|
(main)))
|