Non Promise option to storage

I’m not sure about you guys, but wouldn’t it be nice if we had a non-promise option to storage? I’m trying to move all my code away from localStorage so I don’t ever have to worry about losing tokens.

There’s times where I want to check if something exists, or assign something without a promise. For example;

rootPage:any = localStorage.getItem('token') ? : WelcomePage : LoginPage;

or

this.token = localStorage.getItem('token');

There’s other scenarios where this would be handy I’m sure.

2 Likes

If you don’t want to use localStorage (that is synchronous) then you need to use some other storage mechanism, and IndexedDB for one is async, so if you don’t use promises you’ll have to use it with callbacks which is worse.

Did you find a solution to avoid Promise (Async) usage of Storage ionic 2 ?
I think it’s really annoying for rapid coding.