0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Improve page persistence mechanism.

This commit is contained in:
Andrey Antukh 2017-01-06 18:05:14 +01:00
parent f7e4e18a28
commit b00992881c
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -242,6 +242,10 @@
(s/def ::metadata-persisted-event
(s/keys :req-un [::id ::version]))
(defn metadata-persisted?
[v]
(instance? MetadataPersisted. v))
(defn metadata-persisted
[{:keys [id] :as data}]
{:pre [(us/valid? ::metadata-persisted-event data)]}
@ -399,16 +403,21 @@
(rx/take 1))]
(rx/merge
(->> stream
(rx/take-until stopper)
(rx/filter #(not= @rlocks/lock :shape/resize))
(rx/filter #(satisfies? IPageUpdate %))
(rx/debounce 1000)
(rx/map #(persist-page id)))
(->> stream
(rx/take-until stopper)
(rx/filter #(satisfies? IMetadataUpdate %))
(rx/debounce 1000)
(rx/map #(persist-metadata id)))))))
(rx/mapcat #(rx/merge (rx/of (persist-page id))
(->> (rx/filter page-persisted? stream)
(rx/take 1)
(rx/ignore)))))
(->> stream
(rx/filter #(satisfies? IMetadataUpdate %))
(rx/take-until stopper)
(rx/debounce 1000)
(rx/mapcat #(rx/merge (rx/of (persist-metadata id))
(->> (rx/filter metadata-persisted? stream)
(rx/take 1)
(rx/ignore)))))))))
(defn watch-page-changes
[id]