This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-21
Channels
- # admin-announcements (1)
- # beginners (3)
- # boot (242)
- # clara (1)
- # cljsrn (8)
- # clojars (2)
- # clojure (68)
- # clojure-russia (23)
- # clojure-spec (28)
- # clojure-uk (11)
- # clojurescript (7)
- # datavis (3)
- # datomic (21)
- # emacs (2)
- # events (2)
- # hoplon (56)
- # jobs (3)
- # lambdaisland (1)
- # mount (20)
- # off-topic (4)
- # om (13)
- # onyx (17)
- # other-languages (2)
- # parinfer (7)
- # proto-repl (2)
- # proton (2)
- # protorepl (53)
- # re-frame (13)
- # reagent (3)
- # ring-swagger (22)
- # specter (5)
@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.
@mnewhook Does this help: https://github.com/Day8/re-frame/wiki/Using-Stateful-JS-Components
Thanks Mike, thats almost exactly what I used. See https://clojurians.slack.com/archives/reagent/p1471741656001190 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
(reg-event-db
:update-state
[debug (path :contacts) trim-v]
(fn
[_ [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.