The Oracle
The Oracle

Reputation: 2503

How to access previous app state/config on app relaunch (TornadoFx)

After looking at state/settings, configuration, I have tried config and app.config for app state/setting management. When I use app.config, I am able to access the state in other views.

I wish to implement state such that when the app is launched a second time, the first view or behavior should be different based on the state config/settings of the previous session.

I realized that each time I relaunch the app all states default to null.

I even came across the notion of configBasedPath and configPath but what I am not sure about is,

This is because after running my app, I do not see the default conf base directory and the app.properties file.

I am currently developing on windows 10 and use FXLauncher for packaging.

How can I persist state in my app such that I can always access the previous states/settings I run the app?

Upvotes: 1

Views: 109

Answers (1)

Edvin Syse
Edvin Syse

Reputation: 7297

To persist configuration changes, simply call save() on the config object. To save the global app config settings, call app.config.save(). Changes are automatically loaded when the app starts.

You can read more about the config object in the guide:

https://github.com/edvin/tornadofx-guide/blob/master/part2/Config%20Settings%20and%20State.md

Upvotes: 1

Related Questions