UNPKG

corello

Version:

Main Kernel

23 lines (22 loc) 644 B
import { IEvent } from '..'; export type TListener<T> = { callback: (e: IEvent<T>) => void; options: { once?: boolean; }; }; export interface IDisposable { dispose(): void; } export interface IDispatcher<T> extends IDisposable { readonly id: string; on(event: IEvent<T>, callback: TListener<T>['callback'], options?: { once?: boolean; }): void; once(event: IEvent<T>, callback: TListener<T>['callback']): void; off(event: IEvent<T>, callback: TListener<T>['callback']): void; dispatch(event: IEvent<T>): boolean | void; turnOn(): void; turnOff(): void; get isOn(): boolean; }