(defmulti mutate om/dispatch)
(defmethod mutate 'increment
[{:keys [state] :as env} key {:keys [new] :as params}]
{:action #(swap! state assoc :count new)})
...
(dom/input #js {:type "text"
:onKeyUp #(om/transact! this `[(increment {:new ~(.. % -target -value)})])})
I have the following message:
core.cljs:9608 Uncaught Error: No method in multimethod 'om-tuto.core/mutate' for dispatch value: om-tuto.core/increment
does anyone knows what is missing?
I've spent the whole afternoon 😞
@vinnyataide: do this: #(om/transact! this [(list 'increment {:new (.. % -target -value)})])
or also could work (not sure) #(om/transact! this `[('increment {:new ~(.. % -target -value)})])
@hlolli tried to change the list format but the message changed to call of undefined :x
nvm
now it worked
I've made a typo, forgot to take out the tilde
I'd rather take that warning seriously, since the first one is probably a namespace error (the backtic one)
ok that explains the error
yeah I gotta learn how to escape properly
is there any way to write the expression more concise? seems very verbose to me
well, I use the list often, got used to it. You could use keyword or anything that is accepted as dispatch for multimethod. But the problem with backtic is that it dereferences the current namespace, kinda shit(when it is unwanted). And the positive side with symbols are that they are visually seperated from keywords in read multimethods. I see reasons for and against using symbols for dispatch, but if that's the cultural usage om, then its better to get used to this habit.
@hlolli: great insight