Releases: Flagsmith/flagsmith-js-client
Releases · Flagsmith/flagsmith-js-client
Version 4.0.2
What's Changed
Full Changelog: 4.0.1...4.0.2
v4.0.1 Fix onChange Generic Types
v4.0.0 - add list of changed flags/traits, improve resolve/reject of init
This will be the first version compatible with OpenFeature. Merges #223
Breaking changes
- Init will now reject if:
- No environment ID is provider
- Fetch fails and there's no cache (Init resolves on cache)
- There's no cache/defaults and preventFetch is true
- The boolean properties traitsChange and flagsChanged are now a string[] of changed keys or null. This reduces breaking changes since falsey and truthy checks will still behave as before.
Other changes
- Init is (finally) async/await
- Init code is reduced by pulling out isolated functions
- Added tests around init promises
- Organised util files
3.24.0 - Read cache synchronously
Closes #222
The SDK will now synchronously read cache rather than fetching it asynchronously.
3.23.2 - Remove busy logs, fix onChange event
3.23.1 - Prevent Nextjs caching behaviour
3.23.0 - Fix missed events in useFlags
Closes #214
- Fixes flag updates from useFlags
- Fixes flag updates where flagsmith.init is not called
3.22.1 - Support fallback for non-JSON evaluations
3.22.0 - Prevent race condition between identify/getFlags
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 #205.
3.19.0 - Access Flagsmith loading state
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()