Ionic storage


#1

I have a settingsmenu where I store some simple toogle settings with ionic storage, whats the best way to both make the app respond to the changes and load the values at startup.


#2

I never did this, but eventually I will, and I would solve it something like this:

Create a Service for your configuration, it’ll have default values at start. Each time you make a config change, overwrite the service property value and store it on Storage. Service and Storage must be both updated and synced. When app start up read Storage config values and pass them to Service, which will overwrite default values. On your view, maybe you’ll have conditional states or styles for your view. Maybe [ngStyle.color]="ConfigService.backgroundColor".

I don’t know if it is the best way to achieve this problem, but I think it would work.