Comments (9)
Yes, I have understood the service as so too. First who have to locker.get
the value and assign it to the variable you want to bind. Can someone confirm?
from angular-locker.
Apologies for the late response.
I'm not exactly sure what the issue is here. I have created a demo on codepen here.
Any chance you could provide more context. i.e. the code that is run in the controller or something?
Thanks
from angular-locker.
I think @aj0strow means that he/she expected that by calling bind
you are also watching for changes on the sessionStorage and do an initial sessionStorage.getItem
when binding a property. Is this the case?
from angular-locker.
@eolognt the initial set seems fixed http://codepen.io/anon/pen/PqZOxy
from angular-locker.
Ok, that looks really nice. But I tested if locker watched for changes on the storage as well as the scope. This doesn't seem to be the case (test yourself by modifying localStorage through the console) and thus the values aren't in sync across browser tabs. This also seems to be the primary topic of this issue.
The way to implement this I think would be to listen on 'storage' events, that triggers every time a value for a key in the webstorage is changed or created: https://developer.mozilla.org/en-US/docs/Web/Events/storage And of course separate storage event triggered by locker on the current tab and those who are not.
Btw, why can you only bind values to the scope? I would find it useful to have this in services as well.
from angular-locker.
@eolognt yeah cross tab sync was the other half and doesn't work yet.
I'd imagine the reason for scopes only is the $watch
method.
from angular-locker.
Ok, thanks for clearing that up guys 👍 I now see the issue..
@eolognt I will see if I can implement storage events, as you mentioned, to make sure things are in sync.
This fix will likely be the final thing for the 1.3
release
Cheers!
from angular-locker.
Also.. regarding binding to non scope keys...
@aj0strow is correct, without the $watch
method. I would need to add a Object.observe()
/ Object.watch()
polyfill, which is a whole other thing.
I'm not going to rule it out though, as there are some nice little shims, such as this one.
Just concerned about bloating things too much
from angular-locker.
Tried a couple of things with this.. not 100% happy with the implementation so far...
Just released version 2.0.0 as I didn't want to hold things up too much more.
Going to look at trying to create a more elegant solution
from angular-locker.
Related Issues (20)
- lockerProvider throws error when trying to setDefaultDriver HOT 1
- README out of date HOT 2
- Is it compatible with angular 1.4/material? HOT 1
- [Feature Request] Add where method to find value location HOT 3
- Force invalidation of one item
- Problem when trying to put or access multiple 'session' object. HOT 3
- LocalStorage gets reset on window.history.back()
- locker.put null values HOT 1
- Webpack HOT 8
- Documentation Request - 100% Angular Fallback HOT 1
- Safari Private Browsing HOT 10
- clean() does not work on 'session' driver and namespace with a dot HOT 1
- chrome map.js parsing error HOT 4
- How to bind when using "controller as" syntax? HOT 1
- Why the value in storage after I close the browser HOT 2
- How to save info in each tab in the same browser HOT 2
- Feature request: locker.getDriverName()
- Doc should encourage minification-friendly practice HOT 1
- Plans to add TTL or other expiration concept? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-locker.