mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 19:38:28 +02: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)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue