mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 07:29:08 -05:00
Add the ability to actions subsystem pass payload.
Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
70d126acb5
commit
5d5a0c9ea0
1 changed files with 14 additions and 6 deletions
|
@ -8,14 +8,22 @@
|
||||||
(defonce actions-lock (atom :nothing))
|
(defonce actions-lock (atom :nothing))
|
||||||
(defonce actions-s (rx/bus))
|
(defonce actions-s (rx/bus))
|
||||||
|
|
||||||
|
;; TODO: implement that as multimethod for add specific validation
|
||||||
|
;; layer for different kind of action payloads
|
||||||
|
|
||||||
(defn acquire-action!
|
(defn acquire-action!
|
||||||
[type]
|
([type]
|
||||||
(when-let [result (compare-and-set! actions-lock :nothing type)]
|
(acquire-action! type nil))
|
||||||
;; (println "acquire-action!" type)
|
([type payload]
|
||||||
(rx/push! actions-s type)))
|
(when-let [result (compare-and-set! actions-lock :nothing type)]
|
||||||
|
(rx/push! actions-s {:type type :payload payload}))))
|
||||||
|
|
||||||
(defn release-action!
|
(defn release-action!
|
||||||
[type]
|
[type]
|
||||||
(when-let [result (compare-and-set! actions-lock type :nothing)]
|
(when-let [result (compare-and-set! actions-lock type :nothing)]
|
||||||
;; (println "release-action!" type)
|
(rx/push! actions-s {:type :nothing})))
|
||||||
(rx/push! actions-s :nothing)))
|
|
||||||
|
(defn release-all-actions!
|
||||||
|
[]
|
||||||
|
(reset! actions-lock :nothing)
|
||||||
|
(rx/push! actions-s {:type :nothing}))
|
||||||
|
|
Loading…
Add table
Reference in a new issue