@protorians/signalable
Version:
Signal's Events Manager
70 lines (69 loc) • 1.7 kB
TypeScript
import type { ISignalable, ISignalables, ISignalEntries, ISignalListenOption } from "../types/index.js";
/**
* Signal Manager
*/
export declare class Signalable<I, D> implements ISignalable<I, D> {
constructor(signalable: I);
/**
* Get the object on which the signal management is grafted
*/
get signalable(): I;
/**
* Add a listener callback
* @param options
*/
listen(options: ISignalListenOption<I, D>): this;
/**
* Dispatch all listen callback
* @param payload
*/
dispatch(payload: D): this;
/**
* Cancel signal execution
*/
cancel(): this;
status(status: boolean): this;
/**
* Signal option
* @param index
*/
option(index: number): ISignalListenOption<I, D>;
get options(): ISignalListenOption<I, D>[];
}
/**
* Signal Managers
*/
export declare class Signalables<I, B> implements ISignalables<I, B> {
constructor(signalable: I);
/**
* Get Signalable all entries
*/
get entries(): ISignalEntries<I, B>;
/**
* Get the object on which the signal management is grafted
*/
get signalable(): I;
/**
* Add a listener callback
* @param type
* @param callback
*/
listen<K extends keyof B>(type: K, callback: ISignalListenOption<I, B[K]>): this;
/**
* Dispatch all listen callback
* @param type
* @param payload
*/
dispatch<K extends keyof B>(type: K, payload: B[K]): this;
/**
* Clean Signalable
*/
reset(): this;
/**
* Get Signalable entry
* @param type
*/
entry(type: keyof B): ISignalEntries<I, B>[keyof B];
}