Git Product home page Git Product logo

Comments (17)

MikaAK avatar MikaAK commented on September 27, 2024 9

Progress update, just working on getting tests to pass, I've already got the build to complete with AoT

from angular-safeguard.

MikaAK avatar MikaAK commented on September 27, 2024 4

Will release with next version thanks for all the info

from angular-safeguard.

achanthamynavong avatar achanthamynavong commented on September 27, 2024 3

Any update on the fix?

from angular-safeguard.

tobiasmuecksch avatar tobiasmuecksch commented on September 27, 2024

Here is a similar issue with another angular 2 module.

andrucz/ionic2-rating#4

It looks like this is an issue with angular2-locker, not supporting ngc.

The author of this module fixed it with this commit:
andrucz/ionic2-rating@19a8bb8

from angular-safeguard.

tobiasmuecksch avatar tobiasmuecksch commented on September 27, 2024

Potential fix in this stack overflow answer:

http://stackoverflow.com/a/39868123/1646019

from angular-safeguard.

MikaAK avatar MikaAK commented on September 27, 2024

This is proving to be more difficult than expected. I may have to release this with an update since it's not working when I try adding in AoTPlugin

from angular-safeguard.

tobiasmuecksch avatar tobiasmuecksch commented on September 27, 2024

Okay. No hurry.

from angular-safeguard.

MikaAK avatar MikaAK commented on September 27, 2024

Doing AoT requires a bit of a change. The new api can either be

locker.put(DRIVERS.SESSION, 'key', value)
or a different injectable for each type
sessionLocker.put('key', value)
cookieLocker.put('key', value)

I'm inclined to use the former as it allows for more dynamic code (plus fallbacks can be done automatically vs having to do a check such as sessionLocker.supported() ? sessionLocker.put() : memoryLocker.put() and is easier to test. What are your opinions @tobiasmuecksch , @VuongN?

from angular-safeguard.

VuongN avatar VuongN commented on September 27, 2024

At first impression, I like sessionLocker.put('key', value) for the neat syntax and decoupling because each driver can do different things so you'd end up with a less complicated locker.put. I hear you about the testing bit though.

from angular-safeguard.

tobiasmuecksch avatar tobiasmuecksch commented on September 27, 2024

@MikaAK Well. In my opinion both approaches aren't very convenient. If I had to choose one, I'd take the first option.

But how about having some kind of wrapper?

Like:

let myLocker = locker.getLocker(DRIVERS.SESSION);
locker.put('key', value);

The getLocker method (the name isn't optimal, but I didn't come up with a better one) creates a wrapper which does locker.put(DRIVERS.SESSION, 'key', value) when calling the put() method.

from angular-safeguard.

MikaAK avatar MikaAK commented on September 27, 2024

Unfortunately there is no way to return a new instance of itself because that breaks AoT so a getLocker method would end with the locker being just a wrapper to get storages which then begs the question why not just use way 1 with a separate type for each. I'm still leaning towards way two however as it will mean less on the user side to handle non supported drivers especially since in the case of safari private session and localstorage are unavailable so it would error unless you started doing checks and falling back to memory driver each time. I've already finished implementing way 2 as it was the easiest to switch to so I will probably release that and then see if there's to much complaint. Alternatively way 2 also allows for more expansion as users can create your own driver types .

Also each driver does the exact same thing anyway and the methods would be the same globally. You can expire session and localstorage the way I have it set up the same way you expire cookies

from angular-safeguard.

tobiasmuecksch avatar tobiasmuecksch commented on September 27, 2024

@MikaAK Roger. I think this information should then be mentioned (with a short statement why) in the readme in order to prevent confusion.

from angular-safeguard.

Saratov avatar Saratov commented on September 27, 2024

Hi! Could you release fixed version on this week?

from angular-safeguard.

rsnj avatar rsnj commented on September 27, 2024

Any updates on this issue? We are looking for a way to handle local storage in Angular and came across your project. Unfortunately, our project is using AOT and haven't been able to integrate your library. Thanks!

from angular-safeguard.

MikaAK avatar MikaAK commented on September 27, 2024

I do have the work done but unfortunately the tests need to change to accommodate the new style. I can push up the code to master once I'm home so you can begin to use it. Unfortunately I've been very busy with work and another side project that I've had no time to fix the tests. But I'll give it a stab over the weekend if I finish my other tasks.

from angular-safeguard.

onerandomgig avatar onerandomgig commented on September 27, 2024

Hi @MikaAK, Thanks for this awesome library. Were you able to push your AoT changes. I made some local changes to get this working with AoT but when i run in Safari Private Mode, I get this weird error - EXCEPTION: Can't find variable: DEV .... Any thoughts on this?

from angular-safeguard.

MikaAK avatar MikaAK commented on September 27, 2024

@onerandomgig it is pushed! The error is due to not being built and having compiler variables in the code

from angular-safeguard.

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.