Fix opt-in flag typing and bootstrap loading state - #697
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OptInFlag.keyto each SDK's generatedFlagKey, so values returned byuseOptInFlags()pass directly touseSetOptIn()getIsLoadingOptInFlags()and theoptInFlagsLoadingUpdatedevent{ flags, isLoading }from the React and VueuseOptInFlags()APIsisLoadingonly while bootstrapped providers fetch opt-in metadata on first use; regular providers continue to useuseIsLoading()for their normal initial flags requestAPI
React:
Vue (both values are computed refs and are automatically unwrapped in templates):
With a bootstrapped provider,
isLoadingis true while fetching opt-in metadata on first use. With a regular provider, opt-in metadata arrives with the normal flags response anduseIsLoading()covers that initial request.Unaugmented SDK consumers still get string flag keys; generated/augmented consumers get their existing
FlagKeyunion without weakening other typed flag APIs.Tests
Added coverage for:
Flagstype augmentation and directflag.keyusage withuseSetOptIn()Commands run:
yarn workspace @reflag/browser-sdk testyarn workspace @reflag/react-sdk testyarn workspace @reflag/react-sdk test:typesyarn workspace @reflag/vue-sdk testyarn workspace @reflag/vue-sdk test:typesyarn lintyarn fmtyarn workspace @reflag/browser-sdk buildyarn workspace @reflag/react-sdk buildyarn workspace @reflag/react-native-sdk buildyarn workspace @reflag/vue-sdk buildyarn changeset status