CommandHandlingMixin
Hierarchy
OneToOneHandlingMixin
↳ CommandHandlingMixin
Implements
- Controller
- Sender
- Controller
- Sender
Index
Constructors
Properties
Methods
- ensureHandleability
- getHandleableTypes
- getHandled
- getHandledCommands
- getHandledEvents
- getHandledMessages
- getHandledTypes
- getHandledTypesNames
- getHandler
- getHandlerOrThrow
- getHandlers
- getTypeByHandler
- handle
- handles
- hasHandler
- initialize
- isHandleabe
- overrideHandler
- registerCommandHandler
- registerHandler
- removeHandler
- send
- setHandleableTypes
- subscribes
Constructors
constructor
+ new CommandHandlingMixin(): CommandHandlingMixin
Inherited from HandlingMixin.constructor
Overrides void
Returns: CommandHandlingMixin
Properties
commandBus
• commandBus: CommandBus
Methods
ensureHandleability
▸ ensureHandleability(messageType
: MessageType‹Message›, handleableTypes?
: MessageType‹Message› | MessageType‹Message›[]): boolean
Implementation of Sender
Inherited from HandlingMixin.ensureHandleability
Overrides CancelingEmployment.ensureHandleability
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handleableTypes? | MessageType‹Message› | MessageType‹Message›[] |
Returns: boolean
getHandleableTypes
▸ getHandleableTypes(): MessageType‹Message›[]
Implementation of Sender
Inherited from HandlingMixin.getHandleableTypes
Overrides CancelingEmployment.getHandleableTypes
Returns: MessageType‹Message›[]
getHandled
▸ getHandled(messageType
: MessageType‹Message›): MessageType‹Message›[]
Implementation of Sender
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 Sender
Inherited from HandlingMixin.getHandledTypes
Overrides CancelingEmployment.getHandledTypes
Returns: MessageType‹Message›[]
getHandledTypesNames
▸ getHandledTypesNames(): TypeName[]
Inherited from HandlingMixin.getHandledTypesNames
Overrides CancelingEmployment.getHandledTypesNames
Returns: TypeName[]
getHandler
▸ getHandler(messageType
: MessageType‹Message›): Handler | undefined
Implementation of Sender
Inherited from OneToOneHandlingMixin.getHandler
Overrides CancelingEmployment.getHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: Handler | undefined
getHandlerOrThrow
▸ getHandlerOrThrow(messageType
: MessageType‹Message›): Handler
Implementation of Sender
Inherited from OneToOneHandlingMixin.getHandlerOrThrow
Overrides CancelingEmployment.getHandlerOrThrow
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: Handler
getHandlers
▸ getHandlers(): Map‹MessageType‹Message›, Handler | Handler[]›
Implementation of Sender
Inherited from HandlingMixin.getHandlers
Overrides CancelingEmployment.getHandlers
Returns: Map‹MessageType‹Message›, Handler | Handler[]›
getTypeByHandler
▸ getTypeByHandler(handlerReference
: Handler): any | undefined
Inherited from OneToOneHandlingMixin.getTypeByHandler
Overrides CancelingEmployment.getTypeByHandler
Parameters:
Name | Type |
---|---|
handlerReference | Handler |
Returns: any | undefined
handle
▸ handle(message
: Message): Promise‹any›
Inherited from OneToOneHandlingMixin.handle
Overrides void
Parameters:
Name | Type |
---|---|
message | Message |
Returns: Promise‹any›
handles
▸ handles(): Map‹MessageType‹Command›, Handler›
Implementation of Sender
Inherited from HandlingMixin.handles
Overrides CancelingEmployment.handles
Returns: Map‹MessageType‹Command›, Handler›
hasHandler
▸ hasHandler(messageType
: MessageType‹Message›): boolean
Implementation of Sender
Inherited from HandlingMixin.hasHandler
Overrides CancelingEmployment.hasHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: boolean
initialize
▸ initialize(): void
Implementation of Sender
Overrides OneToOneHandlingMixin.initialize
Initializes CommandHandlingMixin.
remarks
By defining handler mappings on metadata with annotations: @handle
and resolving those mapping with handles
method - it ensures, that there
is no leakage in between inheriting classes.
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
overrideHandler
▸ overrideHandler(messageType
: MessageType‹Message›, handler
: Handler): void
Implementation of Sender
Inherited from HandlingMixin.overrideHandler
Overrides CancelingEmployment.overrideHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handler | Handler |
Returns: void
registerCommandHandler
▸ registerCommandHandler(commandType
: MessageType‹Command›, handler
: Handler, shouldOverride?
: boolean): void
Registers command handler and registers that command on command bus.
remarks
Ensure first that handler for command is registrable(i.e. only can
handler can exist for specific Command on whole application)
throws
{UnhandleableTypeError}
Thrown if the type argument is not one of handleable types.
throws
{InvalidHandlerError}
Thrown if the handler argument is not a function.
throws
{HandlerExistError}
Thrown if handler would overridden without explicit call.
Parameters:
Name | Type | Description |
---|---|---|
commandType | MessageType‹Command› | A Command type for which handler mapping will be created. |
handler | Handler | Handler function that will executed upon handling type. |
shouldOverride? | boolean | Flag indicating that handler should be overridden if exist. |
Returns: void
registerHandler
▸ registerHandler(messageType
: MessageType‹Message›, handler
: Handler, shouldOverride?
: boolean): void
Implementation of Sender
Inherited from OneToOneHandlingMixin.registerHandler
Overrides HandlingMixin.registerHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handler | Handler |
shouldOverride? | boolean |
Returns: void
removeHandler
▸ removeHandler(messageType
: MessageType‹Message›): void
Implementation of Sender
Inherited from HandlingMixin.removeHandler
Overrides CancelingEmployment.removeHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: void
send
▸ send(command
: Command): Promise‹any›
Implementation of Sender
Sends(handles) command instance through command bus.
async
Parameters:
Name | Type | Description |
---|---|---|
command | Command | Instance of a Command type. |
Returns: Promise‹any›
Any value that is returned from handler after handling command instance.
setHandleableTypes
▸ setHandleableTypes(handleableTypes
: MessageType‹Message› | MessageType‹Message›[]): void
Implementation of Sender
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 Sender
Inherited from HandlingMixin.subscribes
Overrides CancelingEmployment.subscribes
Returns: Map‹MessageType‹Event›, Handler›