Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating values outside of the addon #315

Open
RobbieTheWagner opened this issue Nov 3, 2019 · 2 comments
Open

Updating values outside of the addon #315

RobbieTheWagner opened this issue Nov 3, 2019 · 2 comments

Comments

@RobbieTheWagner
Copy link

I am having some issues where if I change localStorage manually, outside of Ember, then get the property with storageFor it does not update the values. Is there a way to notify the addon that things changed? I assumed storageFor would be doing basically localStorage.getItem but it appears to be getting old values.

@fsmanuel
Copy link
Member

fsmanuel commented Nov 5, 2019

Hey @rwwagner90
that is actually a good question. storageFor handles a proxy that probably doesn't get notified about the change. Can you provide an example? Is it an object or array?
I would have assumed that the event listener takes care of this but it's been always a bit buggy. So maybe we can figure this out now.

@RobbieTheWagner
Copy link
Author

@fsmanuel it was an object. For example, I had storage:foo and since localStorage doesn't support objects I did like:

const foo = JSON.parse(localStorage.getItem('storage:foo'));
foo.bar = 'baz';
localStorage.setItem('storage:foo', JSON.stringify(foo));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants