Fork me on GitHub
#fulcro
<
2022-11-06
>
roklenarcic13:11:08

What do I do when I want to use uism/trigger-remote-mutation but I don’t want or have an actor to trigger it with?

tony.kay16:11:07

You have to use some actor for context, but it doesn’t really matter which

tony.kay16:11:24

Internally that actor is carried through as the mutation :ref

tony.kay16:11:50

I guess technically it could be nil…but the specs of the functions will give warnings/errors if you do that

tony.kay16:11:30

UISM is really meant to be used with the UI, and therefore there is at least usually AN actor…but you can give it a fake I think and it will still work

tony.kay16:11:38

e.g. :actor/dummy

roklenarcic20:11:38

I have a state machine that controls login. I want to give it a callback to call when login succeeds. What is the best way to do that? Seems that most mechanisms require a serializable “callback”.

tony.kay14:11:32

You can always make a mutation, and pass the mutation as a parameter in event-data (calling a mutation returns the mutation call as serializable data). Technically, since UISM events are only used locally (won’t need to be serialized), you could just put a lambda in the event data.

tony.kay14:11:09

The requirement for serializable is “flexible”. I used to stress it a lot because it enables things like a support UI debugger from production and such. I also personally find callbacks messy, so I try to find better ways. But there are times when you just need them. so, if you don’t mind them looking weird in inspect, etc…you can do it.

roklenarcic14:11:11

Aha, I would like to trigger some loads from that callback so maybe having it as 1 mutation symbol is not the best. Unless I do a mutation that triggers loads and additional mutations from ok-action.

tony.kay14:11:34

why not code the loads into the state machine itself???

roklenarcic14:11:53

Basically I want to decouple “after login” action from the state machine that does login flow

roklenarcic14:11:16

I have some loads I would like to run when user logs in

tony.kay14:11:40

personally I think your entire session management should be in a machine, and should NOT be decoupled…makes it way easier to follow all the possible branches of sesssion madness mess.

roklenarcic14:11:40

and since they come from all over the app, I didn’t want to put them into login machine

roklenarcic14:11:38

like I wanted to have a successful user login trigger, category load, user data load, other entities that are basis for the menus for the logged in user

roklenarcic20:11:14

And unrelated, from the perspective of a Fulcro app, what are the benefits of using React hooks in your components?

tony.kay14:11:57

Hooks, IMO, are much cleaner when you need to have side-effects coded into a component (where you’d normally use componentDidUpdate, etc). The old-class based methods are a mess. Managing refs, making helpers that need to do some async js thing at the UI layer, etc.

tony.kay14:11:46

They also made it way better to create things like use-component for Fulcro, where you can decouple a component from the query tree, which is very handy for places where you want to dynamically adjust things in the UI at runtime.

greg20:11:36

I keep getting through Tony's videos. I noticed two strange issues in Fulcro Inspector: 1/ on mutations the state revisions in the 'DB' tab jumps by 7 Is there any particular reason why? Is it potential 2/ in the transaction's preview ('Transactions' tab), the both diffs shows nil, and one of (or both) states (before, after) is not fetched. Is that common, or yet again, potential misconfiguration?

Jakub Holý (HolyJak)08:11:50

2/ is a known bug in the Inspect 😢 1/ you could go back in history and compare the content of the DB. I guess there are multiple changes underneath.

tony.kay14:11:22

On 1: Fulcro renders on transactions, but Inspect watches all swaps…so every swap you do updates inspect

tony.kay14:11:26

2 is a bug I caused when I switched how inspect gets data. It used to get a delta or full snap of state at every swap, which caused dev apps to be pretty slow. I changed it so that the app tracks history, and just sends inspect a tx number. Inspect can then pull state on demand, but my change didn’t get made to every panel, so some of them don’t know to do it, or don’t do it right.

tony.kay14:11:28

The places I haven’t fixed are the places that I never really use it. It’s been that way for a couple years now with little complaint…I should probably just pull those out so it doesn’t cause confusion