-
Notifications
You must be signed in to change notification settings - Fork 31
chore: localstorage pr feedback #327
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
chore: localstorage pr feedback #327
Conversation
…replaced initializing event with identifying. removed stream and streamingDisabled.
| client.on('ready', () => { | ||
| setState({ client }); | ||
| }); |
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.
ready has been deleted in favor of a simpler design relying only on change.
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.
This was used as the change callback argument but that's been simplified in favor of a string array of flag keys. This is no longer needed.
| // I'm not sure why but both runAllTimersAsync and runAllTicks are required | ||
| // here for the identify promise be resolved | ||
| await jest.runAllTimersAsync(); | ||
| jest.runAllTicks(); |
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.
This could be a bug in jest fake timers.
| } else { | ||
| // manually resolve identify | ||
| this.logger.debug('No changes from PUT'); | ||
| identifyResolve(); |
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.
Callout: manually resolve the identify promise if there are no changes.
| deserializeData: JSON.parse, | ||
| processJson: async (dataJson: Flags) => { | ||
| this.logger.debug(`Streamer PUT: ${Object.keys(dataJson)}`); | ||
| if (initializedFromStorage) { |
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.
As discussed we'll always run the synchronization logic and emit change when there's a change.
| this.logger.debug('Initializing all data from storage'); | ||
| this.logger.debug('Using storage'); | ||
|
|
||
| const changedKeys = calculateFlagChanges(this.flags, flagsStorage); |
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.
Again, like my comment above, always run the sync logic.
| * - `"ready"`: The client has finished starting up. This event will be sent regardless | ||
| * of whether it successfully connected to LaunchDarkly, or encountered an error | ||
| * and had to give up; to distinguish between these cases, see below. | ||
| * - `"initialized"`: The client successfully started up and has valid feature flag | ||
| * data. This will always be accompanied by `"ready"`. | ||
| * - `"failed"`: The client encountered an error that prevented it from connecting to | ||
| * LaunchDarkly, such as an invalid environment ID. All flag evaluations will | ||
| * therefore receive default values. This will always be accompanied by `"ready"`. |
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.
ready has been removed. initialized is replaced by identifying. failed has been removed, in favor of error.
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.
I moved these types to its own folder under types/index.ts so they are easier to reuse.
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.
I removed the config options stream and streamingDisabled for now. For this alpha, streaming will always be on.
| expect(json).toEqual(mockResponse); | ||
| }); | ||
|
|
||
| test('report', async () => { |
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.
I removed useReport from this alpha for now.
713221e
into
yus/sc-225809/use-localstorage-for-bootstrapping-rn-sdk
This implements feedback from #326.
changeevents.readyevent and usechangeinstead.changeis now just a string array of flag keys.streamanduseReportfor now for this alpha.