Enshrine and document existing practice around dispatch-n and nils
This commit is contained in:
parent
9b49b46dd8
commit
6efdae438f
|
@ -81,12 +81,17 @@
|
||||||
;; usage:
|
;; usage:
|
||||||
;; {:dispatch-n (list [:do :all] [:three :of] [:these])}
|
;; {:dispatch-n (list [:do :all] [:three :of] [:these])}
|
||||||
;;
|
;;
|
||||||
|
;; Note: nil events are ignored which means events can be added
|
||||||
|
;; conditionally:
|
||||||
|
;; {:dispatch-n (list (when (> 3 5) [:conditioned-out])
|
||||||
|
;; [:another-one])}
|
||||||
|
;;
|
||||||
(register
|
(register
|
||||||
:dispatch-n
|
:dispatch-n
|
||||||
(fn [value]
|
(fn [value]
|
||||||
(if-not (sequential? value)
|
(if-not (sequential? value)
|
||||||
(console :error "re-frame: ignoring bad :dispatch-n value. Expected a collection, got got:" value)
|
(console :error "re-frame: ignoring bad :dispatch-n value. Expected a collection, got got:" value)
|
||||||
(doseq [event value] (router/dispatch event)))))
|
(doseq [event (remove nil? value)] (router/dispatch event)))))
|
||||||
|
|
||||||
|
|
||||||
;; :deregister-event-handler
|
;; :deregister-event-handler
|
||||||
|
|
Loading…
Reference in New Issue