Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
22ba366
added the api-definition, interfaces, realtime connection and backoff…
Samruddhi90 Aug 8, 2025
77bc5ef
Added TODO and comments
Samruddhi90 Aug 8, 2025
c16eadd
Added the visibilityMonitor
Samruddhi90 Aug 9, 2025
c5d7dfb
resolved the comment about the spacing problem
Samruddhi90 Aug 11, 2025
77a6aca
Fix check failures
Samruddhi90 Aug 11, 2025
4002ed9
minor changes
Samruddhi90 Aug 11, 2025
0ff4893
Fix yarn failures
Samruddhi90 Aug 12, 2025
52686fc
Merge branch 'realtime-backoff' into realtime-visibility-api
Samruddhi90 Aug 12, 2025
6105412
resolving the spacing problem
Samruddhi90 Aug 12, 2025
61ba815
Convert backoff time from seconds to minutes
Samruddhi90 Aug 12, 2025
a98f140
Merge branch 'realtime-backoff' into realtime-visibility-api
Samruddhi90 Aug 12, 2025
c4a8b72
fixed the minor errors
Samruddhi90 Aug 13, 2025
5b23deb
Minor refactoring
Samruddhi90 Aug 13, 2025
960b88e
fixing yarn lint errors
Samruddhi90 Aug 13, 2025
2653ebb
Adding synchronous delay
Samruddhi90 Aug 13, 2025
b8b2751
updating the fetch call
Samruddhi90 Aug 14, 2025
024e042
Closing the connection in a proper way
Samruddhi90 Aug 14, 2025
f882ad4
close connection async
Samruddhi90 Aug 14, 2025
a7d271b
Added the comments
Samruddhi90 Aug 14, 2025
ac82ed7
minor fixes
Samruddhi90 Aug 14, 2025
006127b
Modifying the name of the method `beginRealtimeHttpStream` to `prepar…
Samruddhi90 Aug 18, 2025
874299e
Updating the onConfigUpdate method definition.
Samruddhi90 Aug 18, 2025
412b664
Merge branch 'realtime-for-web' into realtime-handle-notifications
Samruddhi90 Aug 18, 2025
649a2ac
Delete realtime_handler.test.ts
Samruddhi90 Aug 18, 2025
11077d8
fixing the comments.
Samruddhi90 Aug 18, 2025
494af7d
Adding a TODO for X-`Firebase-RC-Fetch-Type` header
Samruddhi90 Aug 20, 2025
385d8bd
Update the errorcodes
Samruddhi90 Aug 20, 2025
f583f8e
minor fix
Samruddhi90 Aug 20, 2025
17b9eb5
Resolving the comment
Samruddhi90 Aug 20, 2025
3eee5f8
Adding changeset
Samruddhi90 Aug 21, 2025
5d43520
Realtime RC test cases (#9210)
Samruddhi90 Aug 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/lemon-baboons-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@firebase/remote-config': minor
'firebase': minor
'@firebase/remote-config-types': minor
---

Added support for Realtime Remote Config for the web. This feature introduces a new `onConfigUpdate` API and allows web applications to receive near-instant configuration updates without requiring periodic polling.
6 changes: 5 additions & 1 deletion common/api-review/remote-config.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ export interface FetchResponse {
config?: FirebaseRemoteConfigObject;
eTag?: string;
status: number;
templateVersion?: number;
}

// @public
export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';

// @public
export type FetchType = 'BASE' | 'REALTIME';

// @public
export interface FirebaseRemoteConfigObject {
// (undocumented)
Expand Down Expand Up @@ -78,7 +82,7 @@ export function isSupported(): Promise<boolean>;
export type LogLevel = 'debug' | 'error' | 'silent';

// @public
export function onConfigUpdate(remoteConfig: RemoteConfig, observer: ConfigUpdateObserver): Promise<Unsubscribe>;
export function onConfigUpdate(remoteConfig: RemoteConfig, observer: ConfigUpdateObserver): Unsubscribe;

// @public
export interface RemoteConfig {
Expand Down
11 changes: 11 additions & 0 deletions docs-devsite/remote-config.fetchresponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface FetchResponse
| [config](./remote-config.fetchresponse.md#fetchresponseconfig) | [FirebaseRemoteConfigObject](./remote-config.firebaseremoteconfigobject.md#firebaseremoteconfigobject_interface) | Defines the map of parameters returned as "entries" in the fetch response body.<p>Only defined for 200 responses. |
| [eTag](./remote-config.fetchresponse.md#fetchresponseetag) | string | Defines the ETag response header value.<p>Only defined for 200 and 304 responses. |
| [status](./remote-config.fetchresponse.md#fetchresponsestatus) | number | The HTTP status, which is useful for differentiating success responses with data from those without.<p>The Remote Config client is modeled after the native <code>Fetch</code> interface, so HTTP status is first-class.<p>Disambiguation: the fetch response returns a legacy "state" value that is redundant with the HTTP status code. The former is normalized into the latter. |
| [templateVersion](./remote-config.fetchresponse.md#fetchresponsetemplateversion) | number | The version number of the config template fetched from the server. |

## FetchResponse.config

Expand Down Expand Up @@ -65,3 +66,13 @@ The HTTP status, which is useful for differentiating success responses with data
```typescript
status: number;
```

## FetchResponse.templateVersion

The version number of the config template fetched from the server.

<b>Signature:</b>

```typescript
templateVersion?: number;
```
17 changes: 15 additions & 2 deletions docs-devsite/remote-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The Firebase Remote Config Web SDK. This SDK does not work in a Node.js environm
| Type Alias | Description |
| --- | --- |
| [FetchStatus](./remote-config.md#fetchstatus) | Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.<ul> <li>"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.</li> <li>"success" indicates the last attempt succeeded.</li> <li>"failure" indicates the last attempt failed.</li> <li>"throttle" indicates the last attempt was rate-limited.</li> </ul> |
| [FetchType](./remote-config.md#fetchtype) | Indicates the type of fetch request.<ul> <li>"BASE" indicates a standard fetch request.</li> <li>"REALTIME" indicates a fetch request triggered by a real-time update.</li> </ul> |
| [LogLevel](./remote-config.md#loglevel) | Defines levels of Remote Config logging. |
| [Unsubscribe](./remote-config.md#unsubscribe) | A function that unsubscribes from a real-time event stream. |
| [ValueSource](./remote-config.md#valuesource) | Indicates the source of a value.<ul> <li>"static" indicates the value was defined by a static constant.</li> <li>"default" indicates the value was defined by default config.</li> <li>"remote" indicates the value was defined by fetched config.</li> </ul> |
Expand Down Expand Up @@ -295,7 +296,7 @@ Starts listening for real-time config updates from the Remote Config backend and
<b>Signature:</b>

```typescript
export declare function onConfigUpdate(remoteConfig: RemoteConfig, observer: ConfigUpdateObserver): Promise<Unsubscribe>;
export declare function onConfigUpdate(remoteConfig: RemoteConfig, observer: ConfigUpdateObserver): Unsubscribe;
```

#### Parameters
Expand All @@ -307,7 +308,7 @@ export declare function onConfigUpdate(remoteConfig: RemoteConfig, observer: Con

<b>Returns:</b>

Promise&lt;[Unsubscribe](./remote-config.md#unsubscribe)<!-- -->&gt;
[Unsubscribe](./remote-config.md#unsubscribe)

An [Unsubscribe](./remote-config.md#unsubscribe) function to remove the listener.

Expand Down Expand Up @@ -384,6 +385,18 @@ Summarizes the outcome of the last attempt to fetch config from the Firebase Rem
export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
```

## FetchType

Indicates the type of fetch request.

<ul> <li>"BASE" indicates a standard fetch request.</li> <li>"REALTIME" indicates a fetch request triggered by a real-time update.</li> </ul>

<b>Signature:</b>

```typescript
export type FetchType = 'BASE' | 'REALTIME';
```

## LogLevel

Defines levels of Remote Config logging.
Expand Down
15 changes: 11 additions & 4 deletions packages/remote-config/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export function getRemoteConfig(
rc._initializePromise = Promise.all([
rc._storage.setLastSuccessfulFetchResponse(options.initialFetchResponse),
rc._storage.setActiveConfigEtag(options.initialFetchResponse?.eTag || ''),
rc._storage.setActiveConfigTemplateVersion(
options.initialFetchResponse.templateVersion || 0
),
rc._storageCache.setLastSuccessfulFetchTimestampMillis(Date.now()),
rc._storageCache.setLastFetchStatus('success'),
rc._storageCache.setActiveConfig(
Expand Down Expand Up @@ -100,6 +103,7 @@ export async function activate(remoteConfig: RemoteConfig): Promise<boolean> {
!lastSuccessfulFetchResponse ||
!lastSuccessfulFetchResponse.config ||
!lastSuccessfulFetchResponse.eTag ||
!lastSuccessfulFetchResponse.templateVersion ||
lastSuccessfulFetchResponse.eTag === activeConfigEtag
) {
// Either there is no successful fetched config, or is the same as current active
Expand All @@ -108,7 +112,10 @@ export async function activate(remoteConfig: RemoteConfig): Promise<boolean> {
}
await Promise.all([
rc._storageCache.setActiveConfig(lastSuccessfulFetchResponse.config),
rc._storage.setActiveConfigEtag(lastSuccessfulFetchResponse.eTag)
rc._storage.setActiveConfigEtag(lastSuccessfulFetchResponse.eTag),
rc._storage.setActiveConfigTemplateVersion(
lastSuccessfulFetchResponse.templateVersion
)
]);
return true;
}
Expand Down Expand Up @@ -369,12 +376,12 @@ export async function setCustomSignals(
*
* @public
*/
export async function onConfigUpdate(
export function onConfigUpdate(
remoteConfig: RemoteConfig,
observer: ConfigUpdateObserver
): Promise<Unsubscribe> {
): Unsubscribe {
const rc = getModularInstance(remoteConfig) as RemoteConfigImpl;
await rc._realtimeHandler.addObserver(observer);
rc._realtimeHandler.addObserver(observer);
return () => {
rc._realtimeHandler.removeObserver(observer);
};
Expand Down
Loading
Loading