UNPKG

@ricardojbd/ngrx-signals-broadcast-sync

Version:

Enables seamless synchronization of state between browser contexts

25 lines (24 loc) 1.57 kB
import { SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals'; import { Options, BroadcastSyncFeatureResult } from './models'; /** * Adds broadcast synchronization capabilities to a Signal Store. * * This function enables state synchronization between multiple clients using the `BroadcastChannel` API. * It allows clients to request, send, and patch the state across multiple contexts. * * @template Input The type of the store feature result, extending `SignalStoreFeatureResult`. * @param channel The name of the broadcast channel to use for synchronizing state across clients. * @returns A Signal Store feature with broadcast capabilities. */ export declare function withBroadcastSync<Input extends SignalStoreFeatureResult>(channel: string): SignalStoreFeature<Input, BroadcastSyncFeatureResult>; /** * Adds broadcast synchronization capabilities to a Signal Store. * * This function enables state synchronization between multiple clients using the `BroadcastChannel` API. * It allows clients to request, send, and patch the state across multiple contexts. * * @template Input The type of the store feature result, extending `SignalStoreFeatureResult`. * @param options A configuration object specifying the broadcast channel and additional behavior for state synchronization. * @returns A Signal Store feature with customizable broadcast capabilities. */ export declare function withBroadcastSync<Input extends SignalStoreFeatureResult>(options: Options<Input['state']>): SignalStoreFeature<Input, BroadcastSyncFeatureResult>;