Code Monkey home page Code Monkey logo

Comments (8)

tdeekens avatar tdeekens commented on July 17, 2024

Thanks for looking more into the adapter. I think it makes perfect sense for the adapter now to clear if the user can be identified as the same. I wanted to avoid flags of user A restoring flags for user B as a sort of "flash or unloaded flags".

from flopflip.

ibratoev avatar ibratoev commented on July 17, 2024

@tdeekens Maybe I don't understand completely the idea of the localstorage adapter.
In my view, a local storage adapter syncs any changes to localstorage and syncs from it on some interval.
Why would you use a localstorage adapter if it cleans up localstorage on page reload. You can just use the memory adapter with the same success.

What is the use case of the localstorage adapter?

from flopflip.

tdeekens avatar tdeekens commented on July 17, 2024

The use case is exactly what you described. I was only wondering what would happen if you user A visit a page. Then flags are persisted to local storage. Then you logout and login as user B. Now flags from user A would be restored. This could be unintended. Maybe it's not worth considering this case though. What's your take on this? :)

from flopflip.

ibratoev avatar ibratoev commented on July 17, 2024

Ah, I think I understand you now. Your concern is when a new user logs in.
My guess is that it is up to the developer to update the adapter when a new user logs in. My guess would be that the localstorage adapter is used in scenarios where the developers have control over where the feature flags come from and when they are updated.

from flopflip.

tdeekens avatar tdeekens commented on July 17, 2024

Yes, either it's a concern we delegate to a consumer of the library or we allow passing in a user key/ID which scopes what is saved and restores it. I think the latter would imply a bit less work for a consumer of the adapter. What do you think?

from flopflip.

ibratoev avatar ibratoev commented on July 17, 2024

Yeah, making it a bit easier with user key/id is fine. But it should be opt-in behaviour. If the user does not provide a user key - it should leave it to the library user for how to control the storage.

@tdeekens, whit all this said, what do you think should be the fix to my original issue - localstorage adapter clears localstorage on page reload without any user key/id provided?

from flopflip.

tdeekens avatar tdeekens commented on July 17, 2024

Sorry for the late reply and latency. Parental leave means keeping an eye on other things :)

I think, if I understand you correctly, what you propose would solve your issue. If a consumer provides a key which can be something the user stores e.g. in localstorage him/herself or is a user uuid than that's used to scope the localstorage items and flags written. It also means that the same flags will be restored if the same uuid is passed between reloads. If one doesn't provide a uuid then the flags are not scoped and one wouldn't prune localstorage. The second is a bit debatable as it would theoretically be an unintended change for some but I think it's for the better.

What do you think?

from flopflip.

tdeekens avatar tdeekens commented on July 17, 2024

Hi, @ibratoev!

This should be closed in #1531. The adapter will now scope it's storage to a user key if passed or persist globally if not. This should prevent the wiping to occur.

from flopflip.

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.