import { Kapp } from '..'; import { THookCallback } from './types'; /** * @class Manages the hooks of an app, a service, or a custom class. */ export declare class HooksManager { /** * @property Contains all the registered hooks. */ private _hooks; /** * @property Contains the event emitter of this hooks manager. When a hook is executed, an event of the same name is triggered. */ private _eventEmitter; /** * Creates a new hook, and initializes its callbacks list. * @param name The name of the new hook. * @throws {HookException} Thrown if the named hook already exists in this manager. */ create(name: string): void; /** * Adds a callback method to the named hook. * @param name The name of the hook you want to add a callback. * @param callback The callback method to execute when the named hook is used. * @param order The default order of the callback. The lowest the value, the first the callback is called. * @throws {HookException} Thrown if the named hook doesn't exist. */ add(name: string, callback: THookCallback, order?: number): void; /** * Adds a listener to a hook event. * @param name The name of the hook event to listen. * @param callback The method to call when the hook is executed. * @throws {HookException} Thrown if the named hook doesn't exist. */ on(name: string, callback: (...params: unknown[]) => void): void; /** * Executes the callbacks of the named hook. Note that the callbacks are ordered ascendingly by their "order" value. * @param name The name of the hook to execute. * @param app The instance of the application. * @param system The instance of the Application, service or custom class that uses this hook. * @param data Eventual data you want to communicate to each hook callback. * @throws {HookException} Thrown if the named hook doesn't exist. */ exec(name: string, app: Kapp, system: TSystem, data?: unknown): Promise; /** * Compares the given hook callbacks infos to sort them. The lowest the order value, the first the callback is placed. * @param hook1 * @param hook2 */ private _compareHookCallbacks; } export default HooksManager;