Hi All, I'm considering using Fulcro in an existing Reagent, Re-frame, and Datascript project and wanted to ask some questions: - Can I easily create specialized indexes in the client-side graph database? In this application's data model, child entities have an attribute to indicate their parent (so instead of :report-page/charts, we have :chart/report-page). Parents need to find their children, and it seems like a normalized graph would require searching every entity to find those which claim the parent. - Probably related to the above, is there a strategy for client-side derived values, like what re-frame offers? In this application entities can have a :name attribute, but if that's missing we'll calculate a derived name from the other attributes of the entity. How would I do that with Fulcro? - What's the incremental adoption story like? Am I going to be swimming upstream if I try to replace individual UI elements or pages of the app one-by-one with Fulcro components?
The normalized db in Fulcro is very very simple, intentionally so. There is no magic, and the logic is trivial: if the EQL has a join, follow an ident at the spot in the db (if there is one). So, the answer to your first two questions is “not built in”, but the format of the db makes it easy for you to reify whatever you want, and that is the intended design: use a statechart or other code unit as the centralization for logic concerns, and leave the database as a pure value, and the UI queries as a fast and simple algorithm. Finding children, as you said, is a simple db->tree against a parent, but if you’re trying to do reverse refs, what I do is usually have pathom manage a translation to forward refs and just query the forward refs (if this is server-derived data). Derived data is always up to you. I intentionally avoided such systems and have spoken about that at length, but I’ll summarize here: There are any number of ways of doing derived data (I personally prefer state machines and state charts to manage overall logic and data derivation). Fulcro’s “hook” is to trigger things through transactions, which can update the db, and then the view is a pure function of the value of the db V = F(db) = React(db->tree(ui-query, db)). I don’t care for “cascading data” systems, in full-stack apps, because they don’t usually play well (are hard to reason about) with side-effecting I/O. statecharts have a distinct advantage in this arena, and hooking those to user-driven events is pretty trivial, traceable, drawable, etc. That said, if you want to add a watch to the Fulcro state atom, or for that matter use an ratom AS Fulcro’s state atom (just force it in there on creation) and trigger renders on the reactive changes or whatever you can certainly hook in. I made a YouTube video on integrating Fulcro with reagent or something a long time ago..it’s probably still valid. As far as “incremental adoption”…hm. couldn’t say. My guess is that it won’t be super fun? re-frame wants to control react, as does Fulcro. If you want two on-page apps running with control of two divs, that could work 😛
Thanks!