angular2-localstorage icon indicating copy to clipboard operation
angular2-localstorage copied to clipboard

Change not detecting

Open lekhnath opened this issue 9 years ago • 5 comments

while changing class property decorated with @SessionStorage() the value stored in SessionStorage indeed changes, but the change is not reflected in decorated property elsewhere in the application. I need to manually refresh to whole browser to restore the value from SessionStorage in decorated property.

lekhnath avatar Aug 06 '16 13:08 lekhnath

elsewhere in the application what do you mean with that? The change detection is only one way: application to storage. We can not detect whether sessionStorage has changed nor want to.

marcj avatar Aug 07 '16 08:08 marcj

By elsewhere in the application, I mean some other components than one that changes the local storage value. Even though the storage value changes after assigning decorated property a new value I am not able to use that recently changed value elsewhere(it is the same elsewhere as above) without refreshing the page. How can I reflect the changes without having to refresh the whole page?

What does this mean? (from README) // register LocalStorage, this registers our change-detection. LocalStorageSubscriber(appPromise);

I assumed that whenever the storage value gets change it automatically changes all the decorated property. What do you suggest to achieve such thing??

lekhnath avatar Aug 07 '16 13:08 lekhnath

I'm seeing the same thing.

For example. I have lists on 3 separate pages--different data. When I start the app initially and go back and forth between the first two lists they never cache and reload from localstorage. If I hit refresh, they do load the cached data. But if I then navigate between the three lists, only the first two load from localStorage. The third one does not unless I refresh the page again after having opened.

@lekhnath Did you have any luck with this?

@marcj I understand you're probably really busy(thus trying to get someone else to maintain.) Any insight would help--I'm going to try to troubleshoot it myself. I'll post something If I find out a workaround.

inmodify avatar Aug 17 '16 02:08 inmodify

@inmodify No, this issue still exists to me. It seems it populates decorated property with LocalStorage value only on initial page reload. It is our job to maintain the changes across the application may be using services. So why not using services only then? That's why I stopped using this repo and created services to manipulate localStorage and sessionStorage. And because, I am using services the change are reflected as they happen.

lekhnath avatar Aug 17 '16 05:08 lekhnath

@lekhnath I can solve the issue by moving all of my services to the global or app level, thank you. That seems like a bad practice, but I think you're right--that would solve my problem, both ways, technically. I may dig back into this, after my deadline, we did this in the durandal world using a knockout extension that wrapped localForage.

inmodify avatar Aug 17 '16 16:08 inmodify