Reading settingsfrom storage


Hello, Im trying to read my settings from ionic/storage so i created a service that will load all the settings if available or load defaults and i did it like this

private theme: BehaviorSubject;

constructor(private storage: Storage) {
this.theme = new BehaviorSubject(‘secondary’); //here im setting the default‘theme’).then(data=>{ //here im trying to read it from the storage if its there

and then i subscribe to this on my page to listen to theme change
return this.theme.asObservable();

my problem is the app load the default theme which is the secondary first and then change it to the saved theme
and i dont want that im sure there is something wrong here can someone tell me how to do it better than this?
i tried doing‘theme’).then(data=>{
else this.theme = new BehaviorSubject(‘secondary’);

but then i get can’t read asObservable of undefined



It’s sort of an unavoidable problem. You could display a loading controller during the time the theme is being retrieved from storage, if that would help.