angular-local-storage icon indicating copy to clipboard operation
angular-local-storage copied to clipboard

What will happen if we set angularLocalStorage.setPrefix to empty

Open razam217 opened this issue 8 years ago • 4 comments

I'm currently getting an error in my IONIC app IOS platform, i.e. After 4,5 hours of closing my app, if I open my app, its localStorage gets empty, and all the data is removed, but if I force quit my app and reopen it, it gets all of its lost data back. I need to know whether what is the exact use of setPrefix, I cannot understand if that is causing this issue.

razam217 avatar Apr 04 '16 09:04 razam217

I have not run a manual test on setting the prefix to empty since early iterations of the codebase, but what will happen is that your keys will be stored in local storage as you set them.

That is to say localStorageService.set('mykey', 12345); will store in local storage with the key "mykey".

The first thing I would check is to make sure you are not acidently calling any of the following: localStorageService.clearAll(); localStorageService.set('mykey', ''); localStorageService.remove('mykey');

Without using the prefix you also run the risk of collision with other apps on your domain using local storage.

grevory avatar Apr 06 '16 18:04 grevory

I haven't used .clearAll() and also I'm not setting any property to ' ' (empty string)... I'm using .remove() but in very right places, and this issue is also different, because if the values are gone (deleted) then how all these values are again restored... :(

razam217 avatar Apr 07 '16 10:04 razam217

Are you binding directly to local storage?

grevory avatar Apr 07 '16 20:04 grevory

No, I'm using a angularLocalStorage library for it. But that also binds directly...

razam217 avatar Apr 08 '16 05:04 razam217