Javascript Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
This will be the first version compatible with OpenFeature. Merges https://github.com/Flagsmith/flagsmith-js-client/pull/223
Breaking changes
Other changes
Closes https://github.com/Flagsmith/flagsmith-js-client/pull/222
The SDK will now synchronously read cache rather than fetching it asynchronously.
Closes https://github.com/Flagsmith/flagsmith-js-client/issues/214
Merges https://github.com/Flagsmith/flagsmith-js-client/pull/213, thanks to @levrik
Prior to this release, clients that request identified/unidentified flags simultaneously could see the wrong results due to a race condition. Although this signifies incorrect usage of the SDK, this will no longer occur.
For more information see https://github.com/Flagsmith/flagsmith-js-client/pull/205.
This introduces a strategy to responding to loading state changes in flagsmith
The following will be exposed to Flagsmith:
export declare enum FlagSource {
"NONE" = "NONE",
"DEFAULT_FLAGS" = "DEFAULT_FLAGS",
"CACHE" = "CACHE",
"SERVER" = "SERVER",
}
export declare type LoadingState = {
error: Error | null, // Current error, resets on next attempt to fetch flags
isFetching: bool, // Whether there is a current request to fetch server flags
isLoading: bool, // Whether any flag data exists
source: FlagSource //Indicates freshness of flags
}
It can be consumed via the onChange function of flagsmith.init or the newly introduced useFlagsmithLoading
onChange?: (previousFlags: IFlags<F> | null, params: IRetrieveInfo, loadingState:LoadingState) => void;
const loadingState:LoadingState = useFlagsmithLoading()
This version includes an npm audit fix.