Skip to content

Commit

Permalink
Enshrine and document existing practice around dispatch-n and nils
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-thompson-day8 committed Jul 19, 2017
1 parent 9b49b46 commit 6efdae4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/re_frame/fx.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6efdae4

Please sign in to comment.