How am I supposed to manage global state across vi...
# tornadofx
t
How am I supposed to manage global state across views in a tornadofx application?
I currently have a JavaFX application that has a single global
State
object that holds a lock on the application's data directory. It manages DB migrations and provides for various accessors and mutators on different data stores. So far so good.
I'm also using tornadofx's typed builders for some parts of the UI. This has been nice enough, but it would be nice to move the whole thing into tornadofx. However, the App needs to take an initial View, and the View needs to be able to be access the data via that global State instance. How is the View supposed to get access to it? Does the App hold onto it, and maybe the View can ask for it? Do I need to use a global singleton? Does it need to somehow be divided into Models and use inject() somehow?
w
if you global state is a model, you can just inject() it into any view
t
I think the difficulty I'm having is that the global state isn't valid to use until some initialization has occurred, which might involve a different View.
Maybe I shouldn't bother with tornado's injection and models for this and I should actually just have a true singleton that can be fetched from anywhere by a
State.getSingleton()
call.