fulcro 2024-09-29

I have a file upload state machine definition and I assign unique ids to each running instance (so I can have multiple copies of this state machine running concurrently). What is the best way to "pass" that asm-id into my actor component's query (sine it isn't known at compile-time)? E.g., I might want to do this if I want to render ui based on the current state of the state machine.

Well if I understand you correctly what I would do is add something like :ui/asmid to the query, and then just put the ID in question in the initial state of the component as you merge it at run time. If you're not merging it, which I'm not sure how you wouldn't since you're saying you're creating an arbitrary number of these that can't possibly exist at compile time, but anyway if you somehow got it statically linked into the query tree, just put that ID in the normalized position so that the query can see it.

oh duh, yes yes that's what I should do. Thanks

oh wait, that only solves part of the problem for me. I want my component to rerender when the state machine changes, so I need to include it in the query, e.g., :query [(uism/asm-ident asm-id)]

just include the whole table

[::uism/asm-id '_]

That’s super efficient from the query engine, and will cause a little over-rendering, but that won’t matter in my experience

👍 1