Return nil when registering a handler

This commit is contained in:
Daniel Compton 2016-07-26 16:09:56 +12:00
parent 6df7320f97
commit 0ce1a04930
1 changed files with 5 additions and 4 deletions

View File

@ -63,12 +63,13 @@
\"re-frame.core/reg-event\" or \"re-frame.core/reg-event-fx\" would generally be used."
([event-id handler-fn]
(when (contains? @id->fn event-id)
(console :warn "re-frame: overwriting an event-handler for: " event-id)) ;; allow it, but warn.
(swap! id->fn assoc event-id handler-fn))
(console :warn "re-frame: overwriting an event-handler for: " event-id)) ;; allow it, but warn.
(swap! id->fn assoc event-id handler-fn)
nil)
([event-id middleware handler-fn]
(let [mid-ware (comp-middleware middleware) ;; compose the middleware
midware+hfn (mid-ware handler-fn)] ;; wrap the handler in the middleware
(let [mid-ware (comp-middleware middleware) ;; compose the middleware
midware+hfn (mid-ware handler-fn)] ;; wrap the handler in the middleware
(register-base event-id midware+hfn))))