Comments (8)
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.
@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.
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.
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.
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.
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.
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.
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)
- If launchdarkly adapter cannot establish network connection, an error is thrown in `reconfigure` that cannot be handled. HOT 7
- Dependency installation error HOT 1
- A lot of babel dependecies are failing to install HOT 3
- Release notes HOT 4
- Warning from launchdarkly adapter HOT 12
- Unable to launch demo HOT 1
- Documentation for combine-adapters HOT 5
- Update examples for sdk.clientSideId change HOT 1
- Dependency Dashboard
- Using react-broadcast with localstorage adapter clears the localstorage all the time HOT 7
- Cannot statically analyse `require(…, …)` caused by old version of `clone-deep`. HOT 3
- Next.js bug with React 18 HOT 4
- Default flags are ignored during the first render HOT 2
- ts-deepmerge v3 generates Source Map warnings HOT 2
- Typo: pollingIntervalMs is spelled pollingInteralMs
- Using `untoggledComponent` with `MemoryAdapter` in a vitest unit test causes OOM from re-render loop HOT 1
- A `cachePolicy` to guide behaviour of how cached flags are restored HOT 5
- <ToggleFeature> is typed as React.Component<any> HOT 1
- ConfigureFlopflip causes act error warnings in test environment HOT 15
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 flopflip.