CommandHandlingMixin

Hierarchy

OneToOneHandlingMixin

  • OneToOneHandlingMixin

    CommandHandlingMixin

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new CommandHandlingMixin(): CommandHandlingMixin

Inherited from HandlingMixin.constructor

Overrides void

Returns: CommandHandlingMixin

Properties

commandBus

commandBus: CommandBus

Methods

ensureHandleability

ensureHandleability(messageType: MessageTypeMessage›, handleableTypes?: MessageTypeMessage› | MessageTypeMessage›[]): boolean

Implementation of Sender

Inherited from HandlingMixin.ensureHandleability

Overrides CancelingEmployment.ensureHandleability

Parameters:

NameType
messageTypeMessageTypeMessage
handleableTypes?MessageTypeMessage› | MessageTypeMessage›[]

Returns: boolean


getHandleableTypes

getHandleableTypes(): MessageTypeMessage›[]

Implementation of Sender

Inherited from HandlingMixin.getHandleableTypes

Overrides CancelingEmployment.getHandleableTypes

Returns: MessageTypeMessage›[]


getHandled

getHandled(messageType: MessageTypeMessage›): MessageTypeMessage›[]

Implementation of Sender

Inherited from HandlingMixin.getHandled

Overrides CancelingEmployment.getHandled

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: MessageTypeMessage›[]


getHandledCommands

getHandledCommands(): MessageTypeCommand›[]

Inherited from HandlingMixin.getHandledCommands

Overrides CancelingEmployment.getHandledCommands

Returns: MessageTypeCommand›[]


getHandledEvents

getHandledEvents(): MessageTypeEvent›[]

Inherited from HandlingMixin.getHandledEvents

Overrides CancelingEmployment.getHandledEvents

Returns: MessageTypeEvent›[]


getHandledMessages

getHandledMessages(): MessageTypeMessage›[]

Inherited from HandlingMixin.getHandledMessages

Overrides CancelingEmployment.getHandledMessages

Returns: MessageTypeMessage›[]


getHandledTypes

getHandledTypes(): MessageTypeMessage›[]

Implementation of Sender

Inherited from HandlingMixin.getHandledTypes

Overrides CancelingEmployment.getHandledTypes

Returns: MessageTypeMessage›[]


getHandledTypesNames

getHandledTypesNames(): TypeName[]

Inherited from HandlingMixin.getHandledTypesNames

Overrides CancelingEmployment.getHandledTypesNames

Returns: TypeName[]


getHandler

getHandler(messageType: MessageTypeMessage›): Handler | undefined

Implementation of Sender

Inherited from OneToOneHandlingMixin.getHandler

Overrides CancelingEmployment.getHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: Handler | undefined


getHandlerOrThrow

getHandlerOrThrow(messageType: MessageTypeMessage›): Handler

Implementation of Sender

Inherited from OneToOneHandlingMixin.getHandlerOrThrow

Overrides CancelingEmployment.getHandlerOrThrow

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: Handler


getHandlers

getHandlers(): Map‹MessageTypeMessage›, Handler | Handler[]›

Implementation of Sender

Inherited from HandlingMixin.getHandlers

Overrides CancelingEmployment.getHandlers

Returns: Map‹MessageTypeMessage›, Handler | Handler[]›


getTypeByHandler

getTypeByHandler(handlerReference: Handler): any | undefined

Inherited from OneToOneHandlingMixin.getTypeByHandler

Overrides CancelingEmployment.getTypeByHandler

Parameters:

NameType
handlerReferenceHandler

Returns: any | undefined


handle

handle(message: Message): Promise‹any›

Inherited from OneToOneHandlingMixin.handle

Overrides void

Parameters:

NameType
messageMessage

Returns: Promise‹any›


handles

handles(): Map‹MessageTypeCommand›, Handler

Implementation of Sender

Inherited from HandlingMixin.handles

Overrides CancelingEmployment.handles

Returns: Map‹MessageTypeCommand›, Handler


hasHandler

hasHandler(messageType: MessageTypeMessage›): boolean

Implementation of Sender

Inherited from HandlingMixin.hasHandler

Overrides CancelingEmployment.hasHandler

Parameters:

NameType
messageTypeMessageTypeMessage

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: MessageTypeMessage›, handleableTypes?: MessageTypeMessage› | MessageTypeMessage›[]): boolean

Inherited from HandlingMixin.isHandleabe

Overrides CancelingEmployment.isHandleabe

Parameters:

NameType
messageTypeMessageTypeMessage
handleableTypes?MessageTypeMessage› | MessageTypeMessage›[]

Returns: boolean


overrideHandler

overrideHandler(messageType: MessageTypeMessage›, handler: Handler): void

Implementation of Sender

Inherited from HandlingMixin.overrideHandler

Overrides CancelingEmployment.overrideHandler

Parameters:

NameType
messageTypeMessageTypeMessage
handlerHandler

Returns: void


registerCommandHandler

registerCommandHandler(commandType: MessageTypeCommand›, 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:

NameTypeDescription
commandTypeMessageTypeCommandA Command type for which handler mapping will be created.
handlerHandlerHandler function that will executed upon handling type.
shouldOverride?booleanFlag indicating that handler should be overridden if exist.

Returns: void


registerHandler

registerHandler(messageType: MessageTypeMessage›, handler: Handler, shouldOverride?: boolean): void

Implementation of Sender

Inherited from OneToOneHandlingMixin.registerHandler

Overrides HandlingMixin.registerHandler

Parameters:

NameType
messageTypeMessageTypeMessage
handlerHandler
shouldOverride?boolean

Returns: void


removeHandler

removeHandler(messageType: MessageTypeMessage›): void

Implementation of Sender

Inherited from HandlingMixin.removeHandler

Overrides CancelingEmployment.removeHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: void


send

send(command: Command): Promise‹any›

Implementation of Sender

Sends(handles) command instance through command bus.

async

Parameters:

NameTypeDescription
commandCommandInstance of a Command type.

Returns: Promise‹any›

Any value that is returned from handler after handling command instance.


setHandleableTypes

setHandleableTypes(handleableTypes: MessageTypeMessage› | MessageTypeMessage›[]): void

Implementation of Sender

Inherited from HandlingMixin.setHandleableTypes

Overrides CancelingEmployment.setHandleableTypes

Parameters:

NameType
handleableTypesMessageTypeMessage› | MessageTypeMessage›[]

Returns: void


subscribes

subscribes(): Map‹MessageTypeEvent›, Handler

Implementation of Sender

Inherited from HandlingMixin.subscribes

Overrides CancelingEmployment.subscribes

Returns: Map‹MessageTypeEvent›, Handler