0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-10 14:01:29 -05:00

Move watch-page-changes func on top of history ns.

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

View file

@ -21,6 +21,26 @@
replace-by-id
index-by)]))
;; --- Watch Page Changes
(declare fetch-page-history)
(declare fetch-pinned-page-history)
(defn watch-page-changes
"A function that starts watching for `IPageUpdate`
events emited to the global event stream and just
reacts on them emiting an other event that just
persists the state of the page in an undo stack."
[]
(letfn [(on-value [id]
(rs/emit! (fetch-page-history id)
(fetch-pinned-page-history id)))]
(as-> rs/stream $
(rx/filter udp/page-synced? $)
(rx/delay 500 $)
(rx/map (comp :id :page) $)
(rx/on-value $ on-value))))
;; --- Pinned Page History Fetched
(declare update-history-index)
@ -89,23 +109,6 @@
([id params]
(map->FetchPageHistory (assoc params :id id))))
;; --- Watch Page Changes
(defn watch-page-changes
"A function that starts watching for `IPageUpdate`
events emited to the global event stream and just
reacts on them emiting an other event that just
persists the state of the page in an undo stack."
[]
(letfn [(on-value [id]
(rs/emit! (fetch-page-history id)
(fetch-pinned-page-history id)))]
(as-> rs/stream $
(rx/filter udp/page-synced? $)
(rx/delay 500 $)
(rx/map (comp :id :page) $)
(rx/on-value $ on-value))))
;; --- Select Page History
(defrecord SelectPageHistory [version]