HookableMixin
Hierarchy
- HookableMixin
 
Implements
- Hookable
 - Hookable
 
Index
Methods
Methods
getActions
▸ getActions(): Actions
Implementation of Hookable
Returns a collection of all available actions with matching registered hooks as nested collection.
Returns: Actions
Collection of actions(key) with matching registered hooks as nested collection(value).
getHook
▸ getHook(action: string, id: string): Hook | undefined
Implementation of Hookable
Returns hook for action and id.
example 
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hook is resolved. | 
id | string | Identifier under which hook was was registered. | 
Returns: Hook | undefined
Hook as a function matching declaration, else undefined.
getHookOrThrow
▸ getHookOrThrow(action: string, id: string): Hook
Implementation of Hookable
Returns hook for action and id or throws.
throws {HandlerNotFoundError}
Thrown if there is no hook registered for action with id.
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hook is resolved. | 
id | string | Identifier under which hook was was registered. | 
Returns: Hook
Hook as a function matching declaration, else throws.
getHooks
▸ getHooks(action: string): Mappings
Implementation of Hookable
Returns a collection of all available hooks registered for action.
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hooks are resolved. | 
Returns: Mappings
Collection of hooks.
hasAction
▸ hasAction(action: string): boolean
Implementation of Hookable
Evaluates if hooks for action are registered.
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hook is existence is evaluated. | 
Returns: boolean
Returns true if hooks for action exists, else false.
hasHook
▸ hasHook(action: string, id: string): boolean
Implementation of Hookable
Evaluates if hook for action with id is registered.
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hook is existence is evaluated. | 
id | string | Identifier under which hook was was registered. | 
Returns: boolean
Returns true if hook exists, else false.
overrideHook
▸ overrideHook(action: string, id: string, hook: Hook): void
Implementation of Hookable
Overrides registered hook by action and id or registers a new one.
throws {InvalidHookActionError}
Thrown if the the action argument is not a string.
throws {InvalidHookIdError}
Thrown if the the id argument is not a string.
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hook will be registered(like onConstruction, onSend, onPublish etc.) | 
id | string | Identifier under which hook will be registered for further reference. | 
hook | Hook | Hook as a function matching declaration for required action that will be invoked upon action. | 
Returns: void
registerHook
▸ registerHook(action: string, id: string, hook: Hook, shouldOverride?: boolean): void
Implementation of Hookable
Registers hook by action type and id.
throws {InvalidHookActionError}
Thrown if the the action argument is not a string.
throws {InvalidHookIdError}
Thrown if the the id argument is not a string.
throws {HookAlreadyExistsError}
Thrown if the existing hook with id would be overridden.
example 
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hook will be registered(like onConstruction, onSend, onPublish etc.) | 
id | string | Identifier under which hook will be registered for further reference. | 
hook | Hook | Hook as a function matching declaration for required action that will be invoked upon action. | 
shouldOverride? | boolean | Flag indicating that hook should be overridden if exist. | 
Returns: void
removeHook
▸ removeHook(action: string, id: string): void
Implementation of Hookable
Removes a hook by action and id.
example 
Parameters:
| Name | Type | Description | 
|---|---|---|
action | string | Action for which hook is removed. | 
id | string | Identifier under which hook was was registered. | 
Returns: void