fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
yubrshen 2021-04-01T05:21:11.290200Z

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,

Jakub Holý 2021-04-01T09:45:45.290600Z

Each router has its own uism

2021-04-01T13:30:45.290800Z

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:

❤️ 1
tony.kay 2021-04-01T14:05:06.291Z

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.

tony.kay 2021-04-01T14:07:54.291200Z

The primary thing you want there is the state machine’s state. everything else, is typically a UI component already.

yubrshen 2021-04-01T17:06:22.297800Z

Thank @kevin842 @holyjak @danvingo and @tony.kay for providing concise help to me! This is a great encouraging community!

❤️ 3
nivekuil 2021-04-01T06:35:49.290400Z

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

Josh Wood 2021-04-01T15:58:08.296400Z

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!

❤️ 1
hadils 2021-04-01T16:30:51.297400Z

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

Josh Wood 2021-04-01T16:37:38.297600Z

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

Jakub Holý 2021-04-01T17:09:55.298200Z

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)