UNPKG

json-crdt-repo

Version:

JSON CRDT server and syncing local-first browser client

23 lines (22 loc) 777 B
import { Subject } from 'rxjs'; import type { PubSub } from './types'; export type * from './types'; export declare class PubSubM<Message> implements PubSub<Message> { readonly bus$: Subject<Message>; pub(msg: Message): void; end(): void; } export declare class PubSubBC<Message> extends PubSubM<Message> { readonly bus: string; readonly ch: BroadcastChannel; constructor(bus: string); pub(msg: Message): void; end(): void; } /** * Creates new cross-tab pubsub broadcast channel. Own messages are also received. * * @param bus The name of the broadcast bus, where messages will be published. * @returns A PubSub instance that publishes messages to the specified bus. */ export declare const pubsub: <Events>(bus: string) => PubSub<Events>;