import { Kapp, IService } from '..'; import { HooksManager, THookCallback } from '../hooks'; export declare abstract class Service implements IService { /** * @property The application that uses this service instance. */ private _app; /** * @property The name used for this service instance registration. */ private _name; /** * @property A hooks manager instance for this service. */ private _hooksManager; /** * Gets the application that uses this service instance. */ protected get app(): Kapp; /** * Gets the name used for this service registration. */ protected get name(): string; /** * Gets the Hooks Manager instance of this service. */ protected get hooksManager(): HooksManager; /** * Initializes this service instance. * @param app The application that uses this service. */ init(app: Kapp, name: string): void | Promise; /** * 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. */ hook(hookName: string, callback: THookCallback, order?: number): void; /** * Listen to a hook event from this service's hooks manager. * @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(hookName: string, callback: (...params: unknown[]) => void): void; /** * 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. */ createHook(name: string): 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 data Eventual data you want to communicate to each hook callback. * @throws {HookException} Thrown if the named hook doesn't exist. */ protected execHook(name: string, data?: unknown): Promise; } export default Service;