(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)But when I call (om/transact this [('add/user ~user) :user/list])
, the user's list get updated
I'm missing something?
wait
@souenzzo what is d/transact!
?
is that datascript?
Yep.
I'm missing tempids?
@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.
So that value {keys} on mutate will just work when I'm in the same component?
the :value
on mutate does nothing beyond self-documentation
And that tempids stuff on this value attribute?
i’m aware that datascript and datomic return mappings of tempids to canonical ids, but i’m not sure how this question is relevant.
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 😛 )
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.
afaik that doesn’t really have anything to do with datascript