feat(web): upgrade feature-flag-client to SSE streaming + getValue()
This commit is contained in:
parent
8c90d863a8
commit
09310b7eb8
@ -14,7 +14,12 @@ const client = createFeatureFlagClient({
|
|||||||
baseUrl: `${getBaseUrl()}/api`,
|
baseUrl: `${getBaseUrl()}/api`,
|
||||||
productId: PRODUCT_ID,
|
productId: PRODUCT_ID,
|
||||||
platform: 'web',
|
platform: 'web',
|
||||||
|
useStreaming: true,
|
||||||
pollIntervalMs: 5 * 60 * 1000,
|
pollIntervalMs: 5 * 60 * 1000,
|
||||||
|
getAccessToken: () =>
|
||||||
|
typeof window !== 'undefined'
|
||||||
|
? localStorage.getItem('access_token')
|
||||||
|
: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,6 +40,14 @@ export function getAllFlags(): Readonly<Record<string, boolean>> {
|
|||||||
return client.getAllFlags();
|
return client.getAllFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get a multi-variate flag value. Returns defaultValue if not found. */
|
||||||
|
export function getFeatureValue<T = boolean | string | number | Record<string, unknown>>(
|
||||||
|
key: string,
|
||||||
|
defaultValue: T,
|
||||||
|
): T {
|
||||||
|
return client.getValue(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
/** Stop polling and reset state. Useful for tests. */
|
/** Stop polling and reset state. Useful for tests. */
|
||||||
export function resetFeatureFlags(): void {
|
export function resetFeatureFlags(): void {
|
||||||
client.stop();
|
client.stop();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user