om-next

vinnyataide 2016-08-09T20:14:31.000042Z

(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

vinnyataide 2016-08-09T20:15:50.000045Z

does anyone knows what is missing?

vinnyataide 2016-08-09T20:16:06.000046Z

I've spent the whole afternoon 😞

2016-08-09T20:23:05.000047Z

@vinnyataide: do this: #(om/transact! this [(list 'increment {:new (.. % -target -value)})])

2016-08-09T20:24:54.000048Z

or also could work (not sure) #(om/transact! this `[('increment {:new ~(.. % -target -value)})])

vinnyataide 2016-08-09T20:33:01.000053Z

@hlolli tried to change the list format but the message changed to call of undefined :x

vinnyataide 2016-08-09T20:35:03.000054Z

nvm

vinnyataide 2016-08-09T20:35:07.000055Z

now it worked

vinnyataide 2016-08-09T20:35:36.000056Z

I've made a typo, forgot to take out the tilde

2016-08-09T20:35:37.000057Z

I'd rather take that warning seriously, since the first one is probably a namespace error (the backtic one)

2016-08-09T20:36:09.000058Z

ok that explains the error

vinnyataide 2016-08-09T20:36:13.000059Z

yeah I gotta learn how to escape properly

vinnyataide 2016-08-09T20:38:20.000060Z

is there any way to write the expression more concise? seems very verbose to me

2016-08-09T20:41:29.000061Z

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.

vinnyataide 2016-08-09T22:00:06.000063Z

@hlolli: great insight