Rename apply-event to trim-v, allow handler to get vector of middleware

This commit is contained in:
mike-thompson-day8 2015-02-27 02:07:35 +11:00
parent 42d1d9e0e6
commit 1d2ffb0d4f
2 changed files with 7 additions and 3 deletions

View File

@ -21,7 +21,7 @@
(def path middleware/path)
(def validate middleware/validate)
(def log-events middleware/log-events)
(def apply-event middleware/apply-event)
(def trim-v middleware/trim-v)
@ -32,4 +32,4 @@
([id handler]
(register-handler id pure handler))
([id middleware handler]
(register-handler id (comp pure middleware) handler)))
(register-handler id [pure middleware] handler)))

View File

@ -19,7 +19,11 @@
(swap! id->fn assoc event-id handler-fn))
([event-id middleware handler-fn]
(register event-id (middleware handler-fn))))
(let [mware (if (vector? middleware)
(apply comp middleware) ;; compose the vector of middleware
middleware)
hander-fn (mware handler-fn)]
(register event-id hander-fn))))
;; -- The Event Conveyor Belt --------------------------------------------------------------------