mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
Improved persistence subsystem.
Now is more effisient and only performs the persistence operations only when persistent datata is changed (not the whole state atom)
This commit is contained in:
parent
8201df7014
commit
90dd207e88
3 changed files with 21 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
(ns uxbox.core
|
||||
(:require [beicon.core :as rx]
|
||||
[uxbox.state :as s]
|
||||
[cats.labs.lens :as l]
|
||||
[uxbox.state :as st]
|
||||
[uxbox.router :as rt]
|
||||
[uxbox.rstore :as rs]
|
||||
[uxbox.ui :as ui]
|
||||
|
@ -8,12 +9,24 @@
|
|||
|
||||
(enable-console-print!)
|
||||
|
||||
(defn main
|
||||
"Initialize the storage subsystem."
|
||||
[]
|
||||
(let [lens (l/select-keys [:pages-by-id
|
||||
:projects-by-id])
|
||||
stream (->> (l/focus-atom lens st/state)
|
||||
(rx/from-atom)
|
||||
(rx/debounce 1000)
|
||||
(rx/tap #(println "[save]")))]
|
||||
(rx/on-value stream #(dl/persist-state %))))
|
||||
|
||||
(defonce +setup+
|
||||
(do
|
||||
(println "bootstrap")
|
||||
|
||||
(st/init)
|
||||
(rt/init)
|
||||
(ui/init)
|
||||
|
||||
(rs/emit! (dl/load-data))
|
||||
(rx/on-value s/stream #(dl/persist-state %))))
|
||||
(main)))
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
(:require [beicon.core :as rx]
|
||||
[uxbox.rstore :as rs]))
|
||||
|
||||
(enable-console-print!)
|
||||
|
||||
(defonce state (atom {}))
|
||||
|
||||
(defonce stream
|
||||
|
@ -17,4 +15,8 @@
|
|||
:projects-by-id {}
|
||||
:pages-by-id {}}))
|
||||
|
||||
(rx/to-atom stream state)
|
||||
|
||||
(defn init
|
||||
"Initialize the state materialization."
|
||||
[]
|
||||
(rx/to-atom stream state))
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
[rum "0.6.0"]
|
||||
[bouncer "0.3.3"]
|
||||
[funcool/promesa "0.6.0"]
|
||||
[funcool/beicon "0.3.0"]
|
||||
[funcool/beicon "0.4.0"]
|
||||
[cljsjs/moment "2.10.6-0"]
|
||||
[figwheel-sidecar "0.5.0-2" :scope "test"]
|
||||
[bidi "1.21.0"]
|
||||
|
|
Loading…
Add table
Reference in a new issue