If I don’t have a hooks component, how would I make some kind of process that gets stopped when component is unmounted (e.g. like use-effect does). For instance I start a statechart but I want to signal that statechart to stop when unmounted.
From my perspective this is best done by the logic, which is why I like statecharts. on-exit. Done.
In older systems, I’d recommend doing so in the routing system (dynamic routing has hooks for that).
what is on screen should be up to your logic. Fulcro renders your data tree. You change the data tree, the ui changes. Therefore, changing the data tree via mutations, UISM, statecharts, etc. should be the process whereby you control ALL side effects.
Tying process to UI rendering is a terrible idea in all cases except those that need to manipulate/access the DOM
E.g. I use use-effect in my statechart visualizer because I need to measure the DOM nodes being laid out, and use an async js call to compute results based on those sizes…there’s nothing in my logic that can be done outside of this DOM concern…it’s a DOM layout problem.
But yeah, overall this is why I’m trying to rebuild a UI routing layer in statecharts, so that these kinds of process concerns can be cleanly structured into on-entry/on-exit executable content of the states that also happen to change the state so that certain things appear on the screen.
Thanks
If I don’t user autoforward flag in my statechart invocation, how do I forward events across? A bunch of transitions in the parent chart that have Send element to pass the event?
correct…if you’re using invocations you can either autoforward all events, or send events to it some other way (send nodes or use the external event queue from within script elements). Of course you can also send it events from external code via the event queue as well
Autoforward seems the logical choice in most cases because you’ll be in the state that started the invocation…so you’ll only be forwarding them when that is active.