On Wednesday, March 30, 2016 at 8:00:50 AM UTC+11, Luke Horton wrote:
> 
> With respect to this concern, I wrote up a quick gh issue that may or may not 
> prove helpful to re-frame: https://github.com/Day8/re-frame/issues/160


Thanks for that issue, I'll cycle back around and address it fully in due 
course. But more quickly I can easily answer your question on middleware: 

> middleware - this isn't a weakness of re-frame, more just a design decision, 
> > but I would be interested to hear how people feel about having to attach 
> middleware to each handler independently? I have always thought middleware 
> were orthogonal, app-wide wrappers initialized once and forgotten. I find it 
> > strange that re-frame has a per-handler middleware scenario.


It is very easy to add middleware to all your handlers in one fell swoop. But 
we find it useful to add middleware selectively.  For example, not every 
handler involves an undoable action. 

But if you did want a global set of middleware (eg undoable and denug?) added 
to all handlers you'd do this:

(defn my-register-handler
  ([id handler]
    (re-frame.core/register-handler id [(undoable) debug] handler)))

And, from then on, you'd just use my-register-hander to register all your 
handlers. That would always give you undoable and debug on all your handlers.

In fact, you'd probably write a multi-arity version of my-register-handler so 
you could selectively add further middleware to the global middleware set like 
this:

(defn my-register-handler
  ([id handler]
    (re-frame.core/register-handler id nil handler))
  ([id extra-middleware handler]
    (re-frame.core/register-handler id [(undoable) debug extra-middleware] 
handler)))



--
Mike

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to