On Monday, May 25, 2015 at 4:40:07 AM UTC+10, Daniel Kersten wrote:
> I would have reagent.ratom/run! dispatch events when app-db needs to be 
> modified and handlers would do the modification as usual.
> 
> I originally thought about the on-changes middleware, but that has the 
> shortcoming that it isn't triggered when app-db changes unless the handler 
> doing the changing explicitly includes the middleware, which IMHO leaks 
> concerns all over the place (you now have to remember to add the middleware 
> anywhere that might cause changes you want to react to; makes generic 
> reusable components hard too).

Yeah, I understand exactly what you mean. You don't later want to forget to add 
the middleware to some new event handler - that could be a subtle bug to find.

My solution is to have a standard set of middlewares that I apply to EVERY 
event handler (or group of related event handlers).  The proposed middleware 
would be in this standard set. 

Like this:
https://github.com/Day8/re-frame-template/blob/00a74ad5d7b6e42633e2b84bc94ec1b3fc2aac85/resources/leiningen/new/re_frame/src/cljs/project_name/handlers.cljs#L6-L13

See it used on line 27. (Middleware vectors compose)

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to