CommandBus
Type parameters
▪ T: SuperConstructor
▪ T: SuperConstructor
Hierarchy
SuperPrototypeSelector‹HookableMixin | OneToOneHandlingMixin, this› & HookableMixin‹this› & OneToOneHandlingMixin‹this›
SuperPrototypeSelector‹HookableMixin | OneToOneHandlingMixin, this› & HookableMixin‹this› & OneToOneHandlingMixin‹this›
↳ CommandBus
Implements
- Hookable
- Controller
- CommandBus
- Hookable
- Controller
- CommandBus
Index
Constructors
Methods
- ensureHandleability
- getActions
- getHandleableTypes
- getHandled
- getHandledCommands
- getHandledEvents
- getHandledMessages
- getHandledTypes
- getHandledTypesNames
- getHandler
- getHandlerOrThrow
- getHandlers
- getHook
- getHookOrThrow
- getHooks
- getTypeByHandler
- handle
- handles
- hasAction
- hasHandler
- hasHook
- initialize
- isHandleabe
- onSend
- overrideHandler
- overrideHook
- registerHandler
- registerHook
- removeHandler
- removeHook
- send
- setHandleableTypes
- subscribes
Constructors
constructor
+ new CommandBus(): CommandBus
Overrides HandlingMixin.constructor
Creates an instance of CommandBus. Creates an instance of CommandBus.
Returns: CommandBus
Methods
ensureHandleability
▸ ensureHandleability(messageType
: MessageType‹Message›, handleableTypes?
: MessageType‹Message› | MessageType‹Message›[]): boolean
Implementation of CommandBus
Inherited from HandlingMixin.ensureHandleability
Overrides CancelingEmployment.ensureHandleability
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handleableTypes? | MessageType‹Message› | MessageType‹Message›[] |
Returns: boolean
getActions
▸ getActions(): Actions
Implementation of Hookable
Inherited from HookableMixin.getActions
Overrides CreateEmployee.getActions
Returns: Actions
getHandleableTypes
▸ getHandleableTypes(): MessageType‹Message›[]
Implementation of CommandBus
Inherited from HandlingMixin.getHandleableTypes
Overrides CancelingEmployment.getHandleableTypes
Returns: MessageType‹Message›[]
getHandled
▸ getHandled(messageType
: MessageType‹Message›): MessageType‹Message›[]
Implementation of CommandBus
Inherited from HandlingMixin.getHandled
Overrides CancelingEmployment.getHandled
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: MessageType‹Message›[]
getHandledCommands
▸ getHandledCommands(): MessageType‹Command›[]
Inherited from HandlingMixin.getHandledCommands
Overrides CancelingEmployment.getHandledCommands
Returns: MessageType‹Command›[]
getHandledEvents
▸ getHandledEvents(): MessageType‹Event›[]
Inherited from HandlingMixin.getHandledEvents
Overrides CancelingEmployment.getHandledEvents
Returns: MessageType‹Event›[]
getHandledMessages
▸ getHandledMessages(): MessageType‹Message›[]
Inherited from HandlingMixin.getHandledMessages
Overrides CancelingEmployment.getHandledMessages
Returns: MessageType‹Message›[]
getHandledTypes
▸ getHandledTypes(): MessageType‹Message›[]
Implementation of CommandBus
Inherited from HandlingMixin.getHandledTypes
Overrides CancelingEmployment.getHandledTypes
Returns: MessageType‹Message›[]
getHandledTypesNames
▸ getHandledTypesNames(): TypeName[]
Implementation of CommandBus
Inherited from HandlingMixin.getHandledTypesNames
Overrides CancelingEmployment.getHandledTypesNames
Returns: TypeName[]
getHandler
▸ getHandler(messageType
: MessageType‹Message›): Handler | undefined
Implementation of CommandBus
Inherited from OneToOneHandlingMixin.getHandler
Overrides CancelingEmployment.getHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: Handler | undefined
getHandlerOrThrow
▸ getHandlerOrThrow(messageType
: MessageType‹Message›): Handler
Implementation of CommandBus
Inherited from OneToOneHandlingMixin.getHandlerOrThrow
Overrides CancelingEmployment.getHandlerOrThrow
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: Handler
getHandlers
▸ getHandlers(): Map‹MessageType‹Message›, Handler | Handler[]›
Implementation of CommandBus
Inherited from HandlingMixin.getHandlers
Overrides CancelingEmployment.getHandlers
Returns: Map‹MessageType‹Message›, Handler | Handler[]›
getHook
▸ getHook(action
: string, id
: string): Hook | undefined
Implementation of Hookable
Inherited from HookableMixin.getHook
Overrides CreateEmployee.getHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: Hook | undefined
getHookOrThrow
▸ getHookOrThrow(action
: string, id
: string): Hook
Implementation of Hookable
Inherited from HookableMixin.getHookOrThrow
Overrides CreateEmployee.getHookOrThrow
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: Hook
getHooks
▸ getHooks(action
: string): Mappings
Implementation of Hookable
Inherited from HookableMixin.getHooks
Overrides CreateEmployee.getHooks
Parameters:
Name | Type |
---|---|
action | string |
Returns: Mappings
getTypeByHandler
▸ getTypeByHandler(handlerReference
: Handler): any | undefined
Inherited from OneToOneHandlingMixin.getTypeByHandler
Overrides CancelingEmployment.getTypeByHandler
Parameters:
Name | Type |
---|---|
handlerReference | Handler |
Returns: any | undefined
handle
▸ handle(command
: Command): Promise‹any›
Overrides OneToOneHandlingMixin.handle
Handles command instance.
async
Parameters:
Name | Type | Description |
---|---|---|
command | Command | An instance of Command type. |
Returns: Promise‹any›
Any value returned as a Promise
from handler.
handles
▸ handles(): Map‹MessageType‹Command›, Handler›
Implementation of CommandBus
Inherited from HandlingMixin.handles
Overrides CancelingEmployment.handles
Returns: Map‹MessageType‹Command›, Handler›
hasAction
▸ hasAction(action
: string): boolean
Implementation of Hookable
Inherited from HookableMixin.hasAction
Overrides CreateEmployee.hasAction
Parameters:
Name | Type |
---|---|
action | string |
Returns: boolean
hasHandler
▸ hasHandler(messageType
: MessageType‹Message›): boolean
Implementation of CommandBus
Inherited from HandlingMixin.hasHandler
Overrides CancelingEmployment.hasHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: boolean
hasHook
▸ hasHook(action
: string, id
: string): boolean
Implementation of Hookable
Inherited from HookableMixin.hasHook
Overrides CreateEmployee.hasHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: boolean
initialize
▸ initialize(): void
Implementation of CommandBus
Inherited from OneToOneHandlingMixin.initialize
Overrides void
Returns: void
isHandleabe
▸ isHandleabe(messageType
: MessageType‹Message›, handleableTypes?
: MessageType‹Message› | MessageType‹Message›[]): boolean
Inherited from HandlingMixin.isHandleabe
Overrides CancelingEmployment.isHandleabe
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handleableTypes? | MessageType‹Message› | MessageType‹Message›[] |
Returns: boolean
onSend
▸ onSend(id
: string, hook
: Hook, shouldOverride?
: boolean): void
Implementation of CommandBus
Registers onSend
callback hook.
Parameters:
Name | Type | Description |
---|---|---|
id | string | Identifier under which onSend hook will be defined. |
hook | Hook | Function that will be executed upon sending Command . |
shouldOverride? | boolean | Flag indicating that hook should be overridden if exist. |
Returns: void
overrideHandler
▸ overrideHandler(messageType
: MessageType‹Message›, handler
: Handler): void
Implementation of CommandBus
Inherited from HandlingMixin.overrideHandler
Overrides CancelingEmployment.overrideHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handler | Handler |
Returns: void
overrideHook
▸ overrideHook(action
: string, id
: string, hook
: Hook): void
Implementation of Hookable
Inherited from HookableMixin.overrideHook
Overrides CreateEmployee.overrideHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
hook | Hook |
Returns: void
registerHandler
▸ registerHandler(commandType
: MessageType‹Command›, handler
: Handler, shouldOverride?
: boolean): void
Implementation of CommandBus
Overrides OneToOneHandlingMixin.registerHandler
Registers command handler.
throws
{UnhandleableTypeError}
Thrown if the type argument is not subclass of Command
type.
throws
{InvalidHandlerError}
Thrown if the handler argument is not a function.r
throws
{HandlerExistError}
Thrown if handler would overridden without explicit call.
Parameters:
Name | Type | Description |
---|---|---|
commandType | MessageType‹Command› | A subclass of Command type. |
handler | Handler | Handler function that will executed upon handling type. |
shouldOverride? | boolean | Flag indicating that handler should be overridden if exist. |
Returns: void
registerHook
▸ registerHook(action
: string, id
: string, hook
: Hook, shouldOverride?
: boolean): void
Implementation of Hookable
Inherited from HookableMixin.registerHook
Overrides CreateEmployee.registerHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
hook | Hook |
shouldOverride? | boolean |
Returns: void
removeHandler
▸ removeHandler(messageType
: MessageType‹Message›): void
Implementation of CommandBus
Inherited from HandlingMixin.removeHandler
Overrides CancelingEmployment.removeHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: void
removeHook
▸ removeHook(action
: string, id
: string): void
Implementation of Hookable
Inherited from HookableMixin.removeHook
Overrides CreateEmployee.removeHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: void
send
▸ send(command
: Command): Promise‹any›
Implementation of CommandBus
alias
handle
async
Parameters:
Name | Type |
---|---|
command | Command |
Returns: Promise‹any›
setHandleableTypes
▸ setHandleableTypes(handleableTypes
: MessageType‹Message› | MessageType‹Message›[]): void
Implementation of CommandBus
Inherited from HandlingMixin.setHandleableTypes
Overrides CancelingEmployment.setHandleableTypes
Parameters:
Name | Type |
---|---|
handleableTypes | MessageType‹Message› | MessageType‹Message›[] |
Returns: void
subscribes
▸ subscribes(): Map‹MessageType‹Event›, Handler›
Implementation of CommandBus
Inherited from HandlingMixin.subscribes
Overrides CancelingEmployment.subscribes
Returns: Map‹MessageType‹Event›, Handler›