From 409cd057391fa324b90d965169c25b8a0f3fc152 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 19 Mar 2016 12:48:39 +0200 Subject: [PATCH] Add additional parameter to watch event protocol method. --- src/uxbox/rstore.cljs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/uxbox/rstore.cljs b/src/uxbox/rstore.cljs index 1ce928cf8..4c6bf8174 100644 --- a/src/uxbox/rstore.cljs +++ b/src/uxbox/rstore.cljs @@ -24,7 +24,7 @@ ;; of `UpdateEvent`, `WatchEvent` or `EffectEvent`. (defprotocol WatchEvent - (-apply-watch [event state])) + (-apply-watch [event state s])) ;; An abstraction for perform just side effects. It ;; receives state and its return value is completly @@ -90,9 +90,10 @@ "Initializes the stream event loop and return a stream with model changes." [state] - (let [watch-s (rx/filter watch? bus) - effect-s (rx/filter effect? bus) - update-s (rx/filter update? bus) + (let [stream (rx/map identity bus) + watch-s (rx/filter watch? stream) + effect-s (rx/filter effect? stream) + update-s (rx/filter update? stream) state-s (->> update-s (rx/scan #(-apply-update %2 %1) state) (rx/share))] @@ -101,7 +102,7 @@ ;; pushed to the event-stream bus (as-> watch-s $ (rx/with-latest-from vector state-s $) - (rx/flat-map (fn [[event model]] (-apply-watch event model)) $) + (rx/flat-map (fn [[event model]] (-apply-watch event model stream)) $) (rx/on-value $ emit!)) ;; Process effects: combine with the latest model to process the new effect