-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JS-951] fix: use ember-local-storage for both read & write FF #112
Conversation
@@ -0,0 +1,6 @@ | |||
import Service from '@ember/service' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I right saying that you created this Service, with only 1 property, just to make it easier to mock it during tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the purpose of this property is to be read from instance-initializers/load-feature-controls.js
& keeping consistency between read & write on local-storage....
In other words, I didn't find the way to properly take into account the ember-local-storage
settings in instance-initializers
when reading from local-storage without using this service...
let { content: featureControls } = controlStorageService.get('featuresLS') | ||
if (featureControls) { | ||
Object.keys(featureControls).forEach(flag => { | ||
if (features.get("flags").includes(flag)) { | ||
featureControls[flag] ? features.enable(flag) : features.disable(flag) | ||
} | ||
}) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple suggestion not necessary of course 👍🏻 .
-
Without
if
-
Direct access to flags value with
Object.entries()
But I admit it is less supported thanObject.keys
.
let { content: featureControls } = controlStorageService.get('featuresLS') | |
if (featureControls) { | |
Object.keys(featureControls).forEach(flag => { | |
if (features.get("flags").includes(flag)) { | |
featureControls[flag] ? features.enable(flag) : features.disable(flag) | |
} | |
}) | |
} | |
let featureControls = controlStorageService.get('featuresLS').content ?? {} | |
Object.entries(featureControls).forEach(([ flag, flagValue ]) => { | |
if (features.flags.includes(flag)) { | |
flagValue ? features.enable(flag) : features.disable(flag) | |
} | |
}) |
Fix
Use
ember-local-storage
for both read & write FF to prevent issue whenember-local-storage
options differents from default (#112)This fix #111