From 9326a411e7a76a997aee7c9b6b6bd21d47086ae0 Mon Sep 17 00:00:00 2001 From: Earl St Sauver Date: Sat, 11 Jul 2015 11:52:23 +0700 Subject: [PATCH] Simplify implementation of Middleware Compose The implementation of middleware compose is duplicating behavior already in compose. `(apply comp [])` returns identity. --- src/re_frame/handlers.cljs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/re_frame/handlers.cljs b/src/re_frame/handlers.cljs index b51fa58..7250e1c 100644 --- a/src/re_frame/handlers.cljs +++ b/src/re_frame/handlers.cljs @@ -30,12 +30,9 @@ (cond (fn? v) v ;; assumed to be existing middleware - (vector? v) (let [v (remove nil? (flatten v)) - _ (report-middleware-factories v)] ;; damn error detection! always messes up the code - (cond - (empty? v) identity ;; no-op middleware - (= 1 (count v)) (first v) ;; only one middleware, no composing needed - :else (apply comp v))) + (seq? v) (let [v (remove nil? (flatten v))] + (report-middleware-factories v) + (apply comp v)) :else (warn "re-frame: comp-middleware expects a vector, got: " v)))