Fork me on GitHub
#fulcro
<
2022-06-07
>
Quentin Le Guennec21:06:25

Can I transact a mutation without defining it first? Something like (comp/transact! {:remote ...} ?

Jakub Holý (HolyJak)21:06:50

that would really surprise me

tony.kay21:06:45

defmutation is a macro that emits a defmethod (the defmulti is in mutations ns). The transaction processing system calls that multimethod based on symbols in the tx. So, short answer: no.

tony.kay21:06:41

As an interesting curiosity of when you’d manually write the defmethod yourself, see the data-fetch namespace. Loading is actually defined as a mutation, but using defmethod instead of defmutation.

Quentin Le Guennec21:06:36

And thanks for Fulcro btw, I find it really awesome 🙂

tony.kay21:06:32

If you need some extreme level of dynamism you can always pass parameters to a single mutation and have it do an alternate kind of dynamic dispatch. At the very outer extreme you could even pass a lambda (in tx options, which come through in env), but that of course wouldn’t be full-stack compatible. Using that data fetch load mutation as an example, you could even vary the remote that way, which is why data-fetch defines it as a multimethod instead of using the syntactic sugar.

tony.kay21:06:37

you’re welcome

tony.kay21:06:17

Similar things are done in the UISM namespace for trigger-remote-mutation

tony.kay21:06:02

Finally, you can also override how the internals of the transaction processing work, meaning you could technically make it do really anything you want..but then you’re rewriting half of the internals 🙂