Enshrine and document existing practice around dispatch-n and nils

This commit is contained in:
Mike Thompson 2017-07-20 08:51:44 +10:00
parent 9b49b46dd8
commit 6efdae438f
1 changed files with 6 additions and 1 deletions

View File

@ -81,12 +81,17 @@
;; usage:
;; {: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
:dispatch-n
(fn [value]
(if-not (sequential? 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