Fork me on GitHub
#om
<
2017-10-06
>
souenzzo02:10:30

(defmethod mutate 'add/user
  [{:keys [state]} _ user]
  {:value  {:keys [:user/list]}
   :action (fn [] (d/transact! state [user]))})
When this event occours, It should update :user/list, not? (not updating here)

souenzzo02:10:13

But when I call (om/transact this [('add/user ~user) :user/list]), the user's list get updated

souenzzo02:10:09

I'm missing something?

levitanong09:10:27

@souenzzo what is d/transact!?

levitanong09:10:08

is that datascript?

souenzzo12:10:03

I'm missing tempids?

levitanong12:10:29

@souenzzo if you are making the call to add/user in a component other than the one querying :user/list, there is a big chance that it won’t update. Specifying :user/list in your mutate explicitly ensures that it re-renders.

souenzzo12:10:48

So that value {keys} on mutate will just work when I'm in the same component?

levitanong12:10:18

the :value on mutate does nothing beyond self-documentation

souenzzo12:10:59

And that tempids stuff on this value attribute?

levitanong12:10:43

i’m aware that datascript and datomic return mappings of tempids to canonical ids, but i’m not sure how this question is relevant.

souenzzo13:10:13

https://github.com/omcljs/om/wiki/Quick-Start-(om.next)#a-mutation-function "`tempids` will be discussed later" No docs about tempids (maybe later in time 😛 )

levitanong13:10:23

AFAIK, tempid resolution is on stuff like, if you make a new Thing, and you want to have some identifier, you’d use (om/tempid), send that over to the server, which would resolve that tempid into a real id, and the result of that (datomic) transact would be a mapping from tempid to real id. So in the POST response that you get clientside will include that mapping, then you can pass that into your cb or merge (to be confirmed), and that will automatically switch over those tempids to the real ids.

levitanong13:10:41

afaik that doesn’t really have anything to do with datascript