0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 22:22:43 -05:00

💄 Update run-store helper

This commit is contained in:
Andrey Antukh 2024-08-07 15:47:48 +02:00 committed by Andrés Moya
parent bde1cd3f5f
commit 22f3dba842

View file

@ -42,21 +42,25 @@
([store done events completed-cb] ([store done events completed-cb]
(run-store store done events completed-cb nil)) (run-store store done events completed-cb nil))
([store done events completed-cb stopper] ([store done events completed-cb stopper]
(let [stream (ptk/input-stream store)] (let [stream (ptk/input-stream store)
(->> stream stopper-s (if (fn? stopper)
(rx/take-until (if stopper
(stopper stream) (stopper stream)
(rx/filter #(= :the/end %) stream))) (rx/filter #(= :the/end %) stream))]
(->> stream
(rx/take-until stopper-s)
(rx/last) (rx/last)
(rx/tap (fn [] (rx/tap (fn [_]
(completed-cb @store))) (completed-cb @store)))
(rx/subs! (fn [_] (done)) (rx/subs! (fn [_] (done))
(fn [cause] (fn [cause]
(js/console.log "[error]:" cause)) (js/console.log "[error]:" cause))
(fn [_] (fn [_]
(js/console.log "[complete]")))) (js/console.log "[complete]"))))
(doall (for [event events]
(ptk/emit! store event))) (doseq [event events]
(ptk/emit! store event))
(ptk/emit! store :the/end)))) (ptk/emit! store :the/end))))
(defn get-file-from-store (defn get-file-from-store