Fork me on GitHub

Hi, can I use an atom from another namespace, so when it changes there, my renderer updates? Can I make it trigger an event every time it changes or do I need to make my whole app be based on a subscription model?


In my example I hit a button which runs a function that maps a subfunction. I would like to update a progress bar every time this subfunction finishes.


What is the most elegant way to approach this?


I believe the general idea comes from the re-frame model where the whole app state is derived from a single "source of truth" (, so the easiest way to accomplish that in that model is to have a (nested) map in the central state atom that coordinates those events/subscriptions. This model tends to work well for javafx as the visual rendering happens in a single thread anyways (just like javascript).


but it might be worth looking into which mimics local mutable state with a *state atom in the global state


@jasmin I'm not quite understanding your setup... I think it's better to have a single atom for the whole UI state. If your "logic" has multiple mutable references (e.g. multiple loaders that report progress), it's probably a good idea to add watchers to these refs that update value in UI state ref