Merge pull request #76 from estsauver/cleanup-middleware-compose

Simplify implementation of Middleware Compose
This commit is contained in:
Mike Thompson 2015-07-11 18:40:42 +10:00
commit 8af8c6840f
1 changed files with 3 additions and 6 deletions

View File

@ -30,12 +30,9 @@
(cond (cond
(fn? v) v ;; assumed to be existing middleware (fn? v) v ;; assumed to be existing middleware
(vector? v) (let [v (remove nil? (flatten v)) (seq? v) (let [v (remove nil? (flatten v))]
_ (report-middleware-factories v)] ;; damn error detection! always messes up the code (report-middleware-factories v)
(cond (apply comp v))
(empty? v) identity ;; no-op middleware
(= 1 (count v)) (first v) ;; only one middleware, no composing needed
:else (apply comp v)))
:else (warn "re-frame: comp-middleware expects a vector, got: " v))) :else (warn "re-frame: comp-middleware expects a vector, got: " v)))