-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat(ForcedDecisions): Add forced-decisions APIs to ReactSDKClient and update useDecision hook to reflect changes #133
Conversation
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.
Great work overall!
This is a partial review. I have suggested a few changes and will suggest a few more later today. Overall, this is looking great and heading in the right direction.
6a39b87
to
fbe891d
Compare
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.
The Implementation looks great so far! Can you add unit tests for all the changes you made and all the new functionality you added.
const getCurrentDecision: () => { decision: OptimizelyDecision } = () => ({ | ||
decision: optimizely.decide(flagKey, options.decideOptions, overrides.overrideUserId, overrideAttrs), | ||
}); |
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 probably done to make sure decide
is only called if any of the inputs that it depends on, change. Removing this from a useCallback
hook might result in it being called multiple times on same inputs
src/hooks.ts
Outdated
useEffect(() => { | ||
if (lastUserUpdate) { | ||
setState(prevState => ({ | ||
...prevState, | ||
...getCurrentDecision(), | ||
})); | ||
} | ||
}, [lastUserUpdate]); |
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 whole implementation for forced decision looks great. Can you add unit tests to cover all the scenarios
* @param {optimizely.OptimizelyForcedDecision} forcedDecision | ||
* @memberof OptimizelyReactSDKClient | ||
*/ | ||
public setForcedDecision( |
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.
Can you add unit tests for this?
fbe891d
to
713ae00
Compare
713ae00
to
e50aa5b
Compare
Sherry was working from his fork due to access issues. Now merging it back to the same branch in base repo.
Summary
Add a set of new APIs for forced-decisions to ReactSDKClient.
Also updated
useDecision
hook to autoupdate and reflect changes when forced decisions are set and removed.Test Plan