@parkersoftware/whoson-lib
Version:
Useful whoson related library
41 lines (40 loc) • 1.26 kB
TypeScript
import "./global.helpers";
export declare class Hooks {
private _showCalls;
private _showWarnings;
private _hooks;
private _hookLog;
get showCalls(): boolean;
get showWarnings(): boolean;
constructor(_showCalls?: boolean, _showWarnings?: boolean);
/**
* register a hook
* @param name name of the hook to bind to
* @param callback the function to run when it's called
* @param weight weight by default is 0, the higher the weight the earlier it is called in the hook sequence
*/
register(name: string, callback: Function, weight?: number): void;
/**
* call a hook by name with any args
* @param name the name of the hook to call
* @param args any args you want to pass to the hook
* @returns {number} the amount of hooks called
*/
call(name: string, args?: any): number;
/**
* add a hook call to the hook log
*/
private addHookLog;
/**
* get the last 1000 hook events that have occurred
* @returns {HookEvent[]} an array of recent hook events
*/
HookLogs(): HookEvent[];
}
interface HookEvent {
Timestamp: Date;
Name: string;
Args: any;
Handled: boolean;
}
export {};