-
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(decide): Added useDecide hook #100
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.
I had a couple of questions to clarify. See my comments.
src/hooks.ts
Outdated
@@ -35,6 +35,8 @@ type HookOptions = { | |||
timeout?: number; | |||
}; | |||
|
|||
type decideHooksOptions = HookOptions & { decideOptions?: OptimizelyDecideOption[] }; |
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.
Shouldn't it be uppercase to be consistent? "DecideHooksOptions"
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.
Good catch
src/hooks.ts
Outdated
() => ({ | ||
decision: optimizely.decide(flagKey, options.decideOptions, overrides.overrideUserId, overrideAttrs) | ||
}), | ||
[optimizely, flagKey, 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.
Don't we need dependency on "options.decideOptions"?
If "IGNORE_USER_PROFILE" is added to the option, it'll generate different decision.
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.
yes, it makes sense. i fixed it.
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.
LGTM
Summary
Added a hook which used
decide
api and returnsOptimizelyDecision
object. It also supports auto updating just like other existing hooksTest Plan