What's the purpose of [::uism/asm-id ::TopRouter]
in
(defsc TopChrome [this {:root/keys [router current-session login]}]
{:query [{:root/router (comp/get-query TopRouter)}
{:root/current-session (comp/get-query Session)}
[::uism/asm-id ::TopRouter]
{:root/login (comp/get-query Login)}]
where ::uism
is com.fulcrologic.fulcro.ui-state-machines
the code is from the Fulcro 3 template.
I only know that [::uism/asm-id ::TopRouter]
is related to state machine. It's discussed in Fulcro 3 video tutorial, https://www.youtube.com/watch?v=ppEBySpROMY
but I cannot figure out why it is needed, and how it works.
At the moment, I just need to know the general idea to remember, when I need to revisit it.
Thanks,Each router has its own uism
There is a note in the book here: https://book.fulcrologic.com/#_looking_at_the_running_instance Remember that Fulcro won’t re-render a component unless its props change (they are all pure components). If you use `(get-active-state)` from a UI then you are "grabbing data" without it going through props. In order to get proper refreshes on a component whose UI depends on the current state you must query for that state machine’s data. Including the ident in your query is enough:
That last one^^^. If you don’t query for it, it won’t be in your props. If it isn’t in your props, shouldComponentUpdate will short-circuit rendering. So, simple rule: If you want to see it change, include it in the query. Of course, if you’re the parent of a UI thing that’s easy, but since UISM isn’t a UI thing itself, you have to pull it in explicitly if you want to use it in the UI. The alternative is to alias a UI prop from UISM, but then you’re asking the state machine to “publish” information instead of component “query” for it.
The primary thing you want there is the state machine’s state. everything else, is typically a UI component already.
the vector syntax lets you query for a specific ident. uisms are stored in the state map like everything else, keyed by ::uism/asm-id, so it's querying the ::TopRouter uism so the component will re-render when the uism changes
Trying to use Fulcro/Pathom to make an IOT dashboard. Loving it so far but I have a quick question if anyone can help me out? I see how Fulcro's mutations have the option to trigger Pathom mutations by using :remotes on a c.f.f.a/fulcro-app instance. Is there a way to do that in reverse?? Can I call a Pathom mutation on the backend that will trigger a frontend Fulcro mutation? If so, could someone point me to an example of some sort. Thanks in advance!
Hi @joshuawood2894. I think you are looking for server push. That is not supported out of the box, but there is a Fulcro library for it: https://github.com/fulcrologic/fulcro-websockets
@hadilsabbagh18 Thanks for suggestion! Looks like server push will do what I need. :thanks:
I use Server Sent Events in my app. Simpler (http stuff such as session ls still apply) but more limited (one-way only so not for requests - response, if multiple backend instances than your requests might arrive to a different instance than the one pushing to you)