Skip to content
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: export use-open-feature-client-status with suspense support #1082

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

wichopy
Copy link
Member

@wichopy wichopy commented Nov 10, 2024

This PR

exposes the internal open feature client status hook so developers can act on non-ready resolved states

Related Issues

Fixes #1036

Notes

Follow-up Tasks

How to test

@wichopy wichopy force-pushed the issue-1036 branch 2 times, most recently from 8172213 to f1ff607 Compare November 10, 2024 13:33
@wichopy wichopy changed the title export use open feature client status with suspense support feat: export use-open-feature-client-status with suspense support Nov 10, 2024
* @returns {ProviderStatus} status of the client for this scope
*/
export function useOpenFeatureClientStatus(): ProviderStatus {
export function useOpenFeatureClientStatus(options?: Options) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the great debate of return types 😅

https://www.youtube.com/watch?v=nwSe95uFN8E&t=47s

Comment on lines 37 to 40
const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };

if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {
suspendUntilReady(client);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the code here is identical to the useWhenProviderReady hook - we might want to commonize it into a util.

* @returns {ProviderStatus} status of the client for this scope
*/
export function useOpenFeatureClientStatus(): ProviderStatus {
export function useOpenFeatureClientStatus(options?: Options) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call this hook internally from useWhenProviderReady; we should probably explicitly disable suspense in the call from that hook so we don't suspend when we don't want to (since that hook also has it's own suspense logic).

@toddbaert
Copy link
Member

toddbaert commented Dec 17, 2024

@wichopy Sorry for the delay - KubeCon really slowed things down for us, still playing some catch-up!

I still think this is valuable, and I think you're on the right track. I left some thoughts.

We also need some tests (probably very similar to the other tests involving hooks and suspense).

wichopy and others added 3 commits December 31, 2024 11:31
Signed-off-by: William Chou <[email protected]>
Signed-off-by: Will Chou <[email protected]>
Signed-off-by: Will Chou <[email protected]>
Signed-off-by: Will Chou <[email protected]>
Signed-off-by: Will Chou <[email protected]>
@wichopy wichopy marked this pull request as ready for review December 31, 2024 16:35
@wichopy wichopy requested a review from a team as a code owner December 31, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] export useOpenFeatureClientStatus
3 participants