0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-26 08:45:34 -05:00

Add better docstring for page change watcher on pages ns.

This commit is contained in:
Andrey Antukh 2016-07-31 00:07:42 +03:00
parent 70c5a29862
commit 414b25242d
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -174,13 +174,19 @@
(UpdatePage. id))
(defn watch-page-changes
"A function that starts watching for `IPageUpdate`
events emited to the global event stream and just
reacts emiting an other event in order to perform
the page persistence.
The main behavior debounces the posible emmited
events with 1sec of delay allowing batch updates
on fastly performed events."
[id]
(letfn [(on-value []
(rs/emit! (update-page id)))]
(as-> rs/stream $
(rx/filter #(satisfies? IPageUpdate %) $)
(rx/debounce 2000 $)
(rx/on-next $ on-value))))
(as-> rs/stream $
(rx/filter #(satisfies? IPageUpdate %) $)
(rx/debounce 1000 $)
(rx/on-next $ #(rs/emit! (update-page id)))))
;; --- Update Page Metadata