export type PubsubListener = (...a: A) => (void | Promise); export interface Pubsub { (fn: PubsubListener): () => void; publish(...a: A): Promise; once(): Promise; clear(): void; } /** * simple pub-sub mechanism. * * // create pubsub function * const onCount = pubsub<[string, number]>() * * // subscribe * const stop = onCount((a, b) => console.log(a, b)) * * // publish * onWhatever.publish("count", 123) * * // unsubscribe * stop() * */ export declare function pubsub(): Pubsub;