Fork me on GitHub

@mbertheau > What if you have a handler that needs an effect two times with different parameters each time? The effect handler should be designed to cater for "multiple". For example dispatch-later is designed to handle one or many.


Thanks Mike, thats almost exactly what I used. See for more details.


ugh, so I’m sure that it’s my error somewhere but I’m having a not-fun time trying to figure it out: I am writing a toy CQRS app in Re-Frame to become more familiar with it. I have a websocket listening to the server for updated app-state values and then in the onmessage of the socket I call (dispatch [:update-state new-state]). I can see all the parts work and even see the state map being passed into the handler for :update-state events but then I get a stacktrace in router.cljs like so: Error: No protocol method IAssociative.-assoc defined for type object: [object Object]


event handler looks like:

;; Whatever we get here, that's our state now
 [debug (path :contacts) trim-v]
   [_ [new-state]]
   (:contacts new-state)))


and the thing I’m handing in looks, at least according to debug output, like {:contacts [{:first “a” :middle “q.” :last “contact”} …]}


the stacktrace in router.cljs is happening after debug outputs “Handling re-frame event: <pile of data>” but before it outputs the diff of db


hey, I figured it out! In my “command” handlers I was dispatching a POST as the last position in the sexp, so router.cljs was trying to figure out how to weave the return value of an HTTP call into the db


So I fixed it by just appending db (the input value of the database) to the end of the handler, and now I’m wondering if that’s the “right” way to do a pure command


e.g., I add a contact to the list, before I would send off to the server “add this” and then also add it to the local db, now I don’t do that - I send my change off and wait for the server to reply with a new global state


so there’s nothing actually happening to local state in the handler


@chris_johnson hopefully you should be using the freshly released version 0.8.0, in which case you should be using -fx event handlers.