Fork me on GitHub
#om-next
<
2016-08-09
>
vinnyataide20:08:31

(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

vinnyataide20:08:50

does anyone knows what is missing?

vinnyataide20:08:06

I've spent the whole afternoon 😞

hlolli20:08:05

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

hlolli20:08:54

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

vinnyataide20:08:01

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

vinnyataide20:08:07

now it worked

vinnyataide20:08:36

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

hlolli20:08:37

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

hlolli20:08:09

ok that explains the error

vinnyataide20:08:13

yeah I gotta learn how to escape properly

vinnyataide20:08:20

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

hlolli20:08:29

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.