From b871217bb6023977a6e15a95d526a2acdfe0bd7b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 31 Jul 2016 00:26:21 +0300 Subject: [PATCH] Move watch-page-changes func on top of history ns. --- src/uxbox/main/data/history.cljs | 37 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/uxbox/main/data/history.cljs b/src/uxbox/main/data/history.cljs index e2a81e28a..6b09f27d5 100644 --- a/src/uxbox/main/data/history.cljs +++ b/src/uxbox/main/data/history.cljs @@ -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]