UNPKG

publisher-subscriber-pattern

Version:

Publisher subscriber pattern that can be used with different event emitters including browser window

15 lines (14 loc) 859 B
import { Subscriber } from './subscriber'; export declare type EventCallback<P = {}> = (event: P & Event) => void; export declare type EventName = string; export declare type EventData = [EventCallback, Subscriber[]]; interface ObjectI { [key: string]: unknown; } export declare type EmitterInstance = ObjectI | Record<number | string | symbol, unknown>; export declare type SubscriberInstance = Record<number | string | symbol, unknown>; export declare type SubscriptionFunctions = (eventName: string, eventCallback: EventCallback) => void; export declare type PublisherProps = [EmitterInstance, string, string]; export declare type UnsubscribeFunction = () => void; export declare const isValidEmitter: (emitterInstance: EmitterInstance, addListenerMethodName: string, removeListenerMethodName: string) => emitterInstance is EmitterInstance; export {};