export declare type AnyListener = (...args: any) => void | Promise; export interface Unsubscribe { (): void; } export interface Subscribe { (func: Listener): Unsubscribe; } export interface Pubsub { publish: Listener; dispose: () => void; subscribe: Subscribe; } export interface AnyPubsubsInput { [key: string]: AnyListener; } export declare type Pubsubs = { [K in keyof O]: Pubsub; }; export declare type Pubify

= { [K in keyof P]: P[K]["publish"]; }; export declare type Subify

= { [K in keyof P]: P[K]["subscribe"]; }; export interface Reader { state: Readonly; subscribe: Subscribe<(state: S) => void>; } export interface ReaderContext { reader: Reader; update: () => void; } /** * create a pub/sub context */ export declare function pubsub(): Pubsub; /** * create a separated group of publish and subscribe functions */ export declare function pubsubs(obj: Pubsubs): { publishers: Pubify>; subscribers: Subify>; }; /** * make a state reader */ export declare function makeReader(state: S): ReaderContext;