What's the best way to handle race conditions? For instance, if I have a component A that B depends on, but C depends on A and a state that is set in B. How can I ensure that B is updated before C is updated, since the state update seems to hide reactivity
The best thing to do is to minimize state usage 🙂 Recently refactored a user's notebook to remove all on_change handlers and instances of mo.state() — instead, we updated the code to pass UI elements values through the dataflow graph (built-in reactivity) and constructed new objects from existing ones, instead of mutating existing ones.
In this case, instead of setting a state in B, can you compute a new value, and have C depend on that new value as well as A?
Thanks! That's what I thought as well. So I've refactored to work with mo.ui.dictionary, and I realized I would love to be able to use nested dictionaries for this though, because I want to pass some metadata about the components as well
not exactly, they may hold other marimo objects, yes, and I didn't know that so thanks for pointing that out 🙂 but metadata could include stuff like "id", "tooltip" strings etc, that may be passed to factory methods, i.e. things that aren't marimo objects