Is there a way to queue something after a transaction is done? I currently know two ways to do this:
1) put them in the result-action
section of the defmutation
.
2) use UISMs
I was curious if there's an even lighter way. I wish I could do this ad-hoc for a particular comp/transact!
call. For example, it'd be great if I could just do
... {:onClick (fn [] (comp/transact! this [(my-mutation {})] {:ok-action (...), :error-action (...)}))}
Thanks. Is that something you would do? Or is there a reason you wouldn't do it?
No, I do not do it. But if I had the need you do then that is likely the way I would take.
Normally the post-action is inherently related to the mutation itself so it makes sense to define those two together. But I guess from your writing that that is not the case.
Yes. Make your own varianylt of transact :-)
Hey everyone! 👋 I've been putting off using Fulcro RAD in my project because I wanted to use Crux as a backend database instead of Datomic. However, I have run into a bit of a project structure mess during my exploratory phase so I watched Tony's video "Building Things with Fulcro RAD" and got inspired. In spirit of doing open source for one's own needs, I've developed https://github.com/roterski/fulcro-rad-crux 🎉! I based the plugin heavily on fulcro-rad-datomic - I adapted it to Crux API and cut down Datomic specific features... and it worked! Those few integration tests pass and fulcro-rad-demo seems to be working correctly with it too. I'm going to adapt my project to Fulcro RAD now and I'm optimistic that it'll cut down a lot of complexity. :fulcro: I look forward to hearing your feedback and I welcome any kind of testing, review and/or contribution. 😊
Very cool. Thanks for sharing this effort.
@pt.roterski is there a particular reason for maintaining the crux db in an atom instead of calling (crux.api/db node)
on a globally maintained (e.g. using mount) node instance? thx.
@thomasmoerman thanks for digging into the details and asking the question. Honestly, the main reason for this is that I wanted to mirror fulcro-rad-datomic’s implementation as closely as possible to preserve compatibility and it uses the same pattern: https://github.com/fulcrologic/fulcro-rad-datomic/blob/develop/src/main/com/fulcrologic/rad/database_adapters/datomic.clj#L534 : “The atom is present so that a mutation that modifies the database can choose to update the snapshot of the db being used for the remaining resolvers.” I guess that it still would make sense with crux, right?
nevertheless, both nodes and databases are available globally on pathom env so you can use either one of them, but using database if nothing else saves you the extra crux.api/db call each time as convenience
you still could/should keep nodes on the mount maintained state as it’s done in the fulcro-rad-demo example https://github.com/roterski/fulcro-rad-demo/blob/develop/src/crux/com/example/components/crux.clj it’s just outside of the plugin’s responsibility
Thanks for clarifying!
I'm open to bringing it under fulcrologic namespace when it's vetted enough but until then I'm considering pushing it to clojars under net.clojars.roterski/fulcro-rad-crux - it's my first time publishing anything so I'm still figuring this out. If you want to use it now, you can follow https://github.com/roterski/fulcro-rad-demo and import it as a github dependency UPDATE: I've managed to push it to clojars already https://clojars.org/roterski/fulcro-rad-crux.
datomic features I've dropped include: schemas (crux is schema-less), datomic cloud stuff (crux config is much simpler, you just pass map into it) and the concept of native-id attribute (couldn't figure out if it's needed so I dropped it and want to see how far I can get without it)
Native id support is meant as an optimization (so you don’t have to store a UUID datom), that’s all.
the main difference is that crux stores data per document, not per attribute as datomic so this datom optimization probably doesn't make sense anymore in context of crux - I was just worried it might break some RAD assumptions but if it's just an optimization then I'm less worried about it 😅
I really appreciate how flexible fulcro rad model is and I foresee that after using it more I could just add more crux-specific attributes to facilitate crux's unique features (like bitemporality) - this is just a first, most basic iteration
I’m looking forward to seeing what you come up with.