Fork me on GitHub
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


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.


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 🙂


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.


you’re welcome


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


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 🙂