* Support realtime updates for Rollouts * Map optimization and lint * update changeset
18 KiB
Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
remote-config package
The Firebase Remote Config Web SDK. This SDK does not work in a Node.js environment.
Functions
| Function | Description |
|---|---|
| function(app, ...) | |
| getRemoteConfig(app, options) | |
| function(remoteConfig, ...) | |
| activate(remoteConfig) | Makes the last fetched config available to the getters. |
| ensureInitialized(remoteConfig) | Ensures the last activated config are available to the getters. |
| fetchAndActivate(remoteConfig) | Performs fetch and activate operations, as a convenience. |
| fetchConfig(remoteConfig) | Fetches and caches configuration from the Remote Config service. |
| getAll(remoteConfig) | Gets all config. |
| getBoolean(remoteConfig, key) | Gets the value for the given key as a boolean.Convenience method for calling remoteConfig.getValue(key).asBoolean(). |
| getNumber(remoteConfig, key) | Gets the value for the given key as a number.Convenience method for calling remoteConfig.getValue(key).asNumber(). |
| getString(remoteConfig, key) | Gets the value for the given key as a string. Convenience method for calling remoteConfig.getValue(key).asString(). |
| getValue(remoteConfig, key) | Gets the Value for the given key. |
| onConfigUpdate(remoteConfig, observer) | Starts listening for real-time config updates from the Remote Config backend and automatically fetches updates from the Remote Config backend when they are available. |
| setCustomSignals(remoteConfig, customSignals) | Sets the custom signals for the app instance. |
| setLogLevel(remoteConfig, logLevel) | Defines the log level to use. |
| function() | |
| isSupported() | This method provides two different checks:1. Check if IndexedDB exists in the browser environment. 2. Check if the current browser context allows IndexedDB open() calls. |
Interfaces
| Interface | Description |
|---|---|
| ConfigUpdate | Contains information about which keys have been updated. |
| ConfigUpdateObserver | Observer interface for receiving real-time Remote Config update notifications.NOTE: Although an complete callback can be provided, it will never be called because the ConfigUpdate stream is never-ending. |
| CustomSignals | Defines the type for representing custom signals and their values. The values in CustomSignals must be one of the following types:
|
| FetchResponse | Defines a successful response (200 or 304). Modeled after the native |
| FirebaseExperimentDescription | Defines experiment and variant attached to a config parameter. |
| FirebaseRemoteConfigObject | Defines a self-descriptive reference for config key-value pairs. |
| FirebaseRolloutMetadata | |
| RemoteConfig | The Firebase Remote Config service interface. |
| RemoteConfigOptions | Options for Remote Config initialization. |
| RemoteConfigSettings | Defines configuration options for the Remote Config SDK. |
| Value | Wraps a value with metadata and type-safe getters. |
Type Aliases
| Type Alias | Description |
|---|---|
| FetchStatus | Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
|
| FetchType | Indicates the type of fetch request.
|
| LogLevel | Defines levels of Remote Config logging. |
| Unsubscribe | A function that unsubscribes from a real-time event stream. |
| ValueSource | Indicates the source of a value.
|
function(app, ...)
getRemoteConfig(app, options) {:#getremoteconfig_61d368f}
Signature:
export declare function getRemoteConfig(app?: FirebaseApp, options?: RemoteConfigOptions): RemoteConfig;
Parameters
| Parameter | Type | Description |
|---|---|---|
| app | FirebaseApp | The FirebaseApp instance. |
| options | RemoteConfigOptions | Optional. The RemoteConfigOptions with which to instantiate the Remote Config instance. |
Returns:
A RemoteConfig instance.
function(remoteConfig, ...)
activate(remoteConfig) {:#activate_722a192}
Makes the last fetched config available to the getters.
Signature:
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
Returns:
Promise<boolean>
A Promise which resolves to true if the current call activated the fetched configs. If the fetched configs were already activated, the Promise will resolve to false.
ensureInitialized(remoteConfig) {:#ensureinitialized_722a192}
Ensures the last activated config are available to the getters.
Signature:
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
Returns:
Promise<void>
A Promise that resolves when the last activated config is available to the getters.
fetchAndActivate(remoteConfig) {:#fetchandactivate_722a192}
Performs fetch and activate operations, as a convenience.
Signature:
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
Returns:
Promise<boolean>
A Promise which resolves to true if the current call activated the fetched configs. If the fetched configs were already activated, the Promise will resolve to false.
fetchConfig(remoteConfig) {:#fetchconfig_722a192}
Fetches and caches configuration from the Remote Config service.
Signature:
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
Returns:
Promise<void>
getAll(remoteConfig) {:#getall_722a192}
Gets all config.
Signature:
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
Returns:
Record<string, Value>
All config.
getBoolean(remoteConfig, key) {:#getboolean_476c09f}
Gets the value for the given key as a boolean.
Convenience method for calling remoteConfig.getValue(key).asBoolean().
Signature:
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
| key | string | The name of the parameter. |
Returns:
boolean
The value for the given key as a boolean.
getNumber(remoteConfig, key) {:#getnumber_476c09f}
Gets the value for the given key as a number.
Convenience method for calling remoteConfig.getValue(key).asNumber().
Signature:
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
| key | string | The name of the parameter. |
Returns:
number
The value for the given key as a number.
getString(remoteConfig, key) {:#getstring_476c09f}
Gets the value for the given key as a string. Convenience method for calling remoteConfig.getValue(key).asString().
Signature:
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
| key | string | The name of the parameter. |
Returns:
string
The value for the given key as a string.
getValue(remoteConfig, key) {:#getvalue_476c09f}
Gets the Value for the given key.
Signature:
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
| key | string | The name of the parameter. |
Returns:
The value for the given key.
onConfigUpdate(remoteConfig, observer) {:#onconfigupdate_8b13b26}
Starts listening for real-time config updates from the Remote Config backend and automatically fetches updates from the Remote Config backend when they are available.
If a connection to the Remote Config backend is not already open, calling this method will open it. Multiple listeners can be added by calling this method again, but subsequent calls re-use the same connection to the backend.
Signature:
export declare function onConfigUpdate(remoteConfig: RemoteConfig, observer: ConfigUpdateObserver): Unsubscribe;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
| observer | ConfigUpdateObserver | The ConfigUpdateObserver to be notified of config updates. |
Returns:
An Unsubscribe function to remove the listener.
setCustomSignals(remoteConfig, customSignals) {:#setcustomsignals_aeeb95e}
Sets the custom signals for the app instance.
Signature:
export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
| customSignals | CustomSignals | Map (key, value) of the custom signals to be set for the app instance. If a key already exists, the value is overwritten. Setting the value of a custom signal to null unsets the signal. The signals will be persisted locally on the client. |
Returns:
Promise<void>
setLogLevel(remoteConfig, logLevel) {:#setloglevel_039a45b}
Defines the log level to use.
Signature:
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| remoteConfig | RemoteConfig | The RemoteConfig instance. |
| logLevel | RemoteConfigLogLevel | The log level to set. |
Returns:
void
function()
isSupported() {:#issupported}
This method provides two different checks:
- Check if IndexedDB exists in the browser environment. 2. Check if the current browser context allows IndexedDB
open()calls.
Signature:
export declare function isSupported(): Promise<boolean>;
Returns:
Promise<boolean>
A Promise which resolves to true if a RemoteConfig instance can be initialized in this environment, or false if it cannot.
FetchStatus
Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
- "no-fetch-yet" indicates the [RemoteConfig](./remote-config.remoteconfig.md#remoteconfig_interface) instance has not yet attempted to fetch config, or that SDK initialization is incomplete.
- "success" indicates the last attempt succeeded.
- "failure" indicates the last attempt failed.
- "throttle" indicates the last attempt was rate-limited.
Signature:
export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
FetchType
Indicates the type of fetch request.
- "BASE" indicates a standard fetch request.
- "REALTIME" indicates a fetch request triggered by a real-time update.
Signature:
export type FetchType = 'BASE' | 'REALTIME';
LogLevel
Defines levels of Remote Config logging.
Signature:
export type LogLevel = 'debug' | 'error' | 'silent';
Unsubscribe
A function that unsubscribes from a real-time event stream.
Signature:
export type Unsubscribe = () => void;
ValueSource
Indicates the source of a value.
- "static" indicates the value was defined by a static constant.
- "default" indicates the value was defined by default config.
- "remote" indicates the value was defined by fetched config.
Signature:
export type ValueSource = 'static' | 'default' | 'remote';