Fork me on GitHub

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, 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,


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

Jakub Holý (HolyJak)09:04:45

Each router has its own uism


There is a note in the book here: 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:

❤️ 3

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.


Thank @U797MAJ8M @U0522TWDA @U051V5LLP and @U0CKQ19AQ for providing concise help to me! This is a great encouraging community!

❤️ 9
Josh Wood15:04:08

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!

❤️ 3

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:

Josh Wood16:04:38

@UGNMGFJG3 Thanks for suggestion! Looks like server push will do what I need. thanks

Jakub Holý (HolyJak)17:04:55

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)