Giter Club home page Giter Club logo

Comments (9)

eolognt avatar eolognt commented on May 24, 2024

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.

tymondesigns avatar tymondesigns commented on May 24, 2024

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.

eolognt avatar eolognt commented on May 24, 2024

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.

aj0strow avatar aj0strow commented on May 24, 2024

@eolognt the initial set seems fixed http://codepen.io/anon/pen/PqZOxy

from angular-locker.

eolognt avatar eolognt commented on May 24, 2024

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.

aj0strow avatar aj0strow commented on May 24, 2024

@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.

tymondesigns avatar tymondesigns commented on May 24, 2024

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.

tymondesigns avatar tymondesigns commented on May 24, 2024

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.

tymondesigns avatar tymondesigns commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.