mirror of
https://github.com/penpot/penpot.git
synced 2025-02-07 23:08:24 -05:00
Add helper for asnc stores
This commit is contained in:
parent
ed7aad6c4e
commit
a7e735bd81
1 changed files with 12 additions and 1 deletions
|
@ -10,9 +10,13 @@
|
||||||
[event-type]
|
[event-type]
|
||||||
(fn [stream]
|
(fn [stream]
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/tap #(prn (ptk/type %)))
|
#_(rx/tap #(prn (ptk/type %)))
|
||||||
(rx/filter #(ptk/type? event-type %)))))
|
(rx/filter #(ptk/type? event-type %)))))
|
||||||
|
|
||||||
|
(def stop-on-send-update-indices
|
||||||
|
"Stops on `send-update-indices` function being called, which should be the last function of an event chain."
|
||||||
|
(stop-on :app.main.data.workspace.changes/send-update-indices))
|
||||||
|
|
||||||
;; Support for async events in tests
|
;; Support for async events in tests
|
||||||
;; https://chat.kaleidos.net/penpot-partners/pl/tz1yoes3w3fr9qanxqpuhoz3ch
|
;; https://chat.kaleidos.net/penpot-partners/pl/tz1yoes3w3fr9qanxqpuhoz3ch
|
||||||
(defn run-store
|
(defn run-store
|
||||||
|
@ -36,3 +40,10 @@
|
||||||
(doall (for [event events]
|
(doall (for [event events]
|
||||||
(ptk/emit! store event)))
|
(ptk/emit! store event)))
|
||||||
(ptk/emit! store :the/end))))
|
(ptk/emit! store :the/end))))
|
||||||
|
|
||||||
|
(defn run-store-async
|
||||||
|
"Helper version of `run-store` that automatically stops on the `send-update-indices` event"
|
||||||
|
([store done events completed-cb]
|
||||||
|
(run-store store done events completed-cb stop-on-send-update-indices))
|
||||||
|
([store done events completed-cb stop-on]
|
||||||
|
(run-store store done events completed-cb stop-on)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue