UNPKG

elf-sync-state

Version:
19 lines (18 loc) 660 B
import { Store, StoreValue } from '@ngneat/elf'; import { Observable } from 'rxjs'; export type PartialStore<S extends Store> = Partial<StoreValue<S>>; export type SyncMessage<S extends Store> = { type: 'REQUEST_STATE'; } | { type: 'UPDATE_STATE'; state: PartialStore<S>; }; interface Options<S extends Store> { channel?: string; source?: (store: S) => Observable<PartialStore<S>>; preUpdate?: (event: MessageEvent<SyncMessage<S>>) => SyncMessage<S>; runGuard?: () => boolean; requestState?: boolean; } export declare function syncState<S extends Store>(store: S, options?: Options<S>): BroadcastChannel | undefined; export {};