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