mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
Add helper for asnc stores
This commit is contained in:
@@ -10,9 +10,13 @@
|
||||
[event-type]
|
||||
(fn [stream]
|
||||
(->> stream
|
||||
(rx/tap #(prn (ptk/type %)))
|
||||
#_(rx/tap #(prn (ptk/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
|
||||
;; https://chat.kaleidos.net/penpot-partners/pl/tz1yoes3w3fr9qanxqpuhoz3ch
|
||||
(defn run-store
|
||||
@@ -36,3 +40,10 @@
|
||||
(doall (for [event events]
|
||||
(ptk/emit! store event)))
|
||||
(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)))
|
||||
|
||||
Reference in New Issue
Block a user