CommandBus

Type parameters

T: SuperConstructor

T: SuperConstructor

Hierarchy

Implements

Index

Constructors

Methods

Constructors

constructor

+ new CommandBus(): CommandBus

Overrides HandlingMixin.constructor

Creates an instance of CommandBus. Creates an instance of CommandBus.

Returns: CommandBus

Methods

ensureHandleability

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

Implementation of CommandBus

Inherited from HandlingMixin.ensureHandleability

Overrides CancelingEmployment.ensureHandleability

Parameters:

NameType
messageTypeMessageTypeMessage
handleableTypes?MessageTypeMessage› | MessageTypeMessage›[]

Returns: boolean


getActions

getActions(): Actions

Implementation of Hookable

Inherited from HookableMixin.getActions

Overrides CreateEmployee.getActions

Returns: Actions


getHandleableTypes

getHandleableTypes(): MessageTypeMessage›[]

Implementation of CommandBus

Inherited from HandlingMixin.getHandleableTypes

Overrides CancelingEmployment.getHandleableTypes

Returns: MessageTypeMessage›[]


getHandled

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

Implementation of CommandBus

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 CommandBus

Inherited from HandlingMixin.getHandledTypes

Overrides CancelingEmployment.getHandledTypes

Returns: MessageTypeMessage›[]


getHandledTypesNames

getHandledTypesNames(): TypeName[]

Implementation of CommandBus

Inherited from HandlingMixin.getHandledTypesNames

Overrides CancelingEmployment.getHandledTypesNames

Returns: TypeName[]


getHandler

getHandler(messageType: MessageTypeMessage›): Handler | undefined

Implementation of CommandBus

Inherited from OneToOneHandlingMixin.getHandler

Overrides CancelingEmployment.getHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: Handler | undefined


getHandlerOrThrow

getHandlerOrThrow(messageType: MessageTypeMessage›): Handler

Implementation of CommandBus

Inherited from OneToOneHandlingMixin.getHandlerOrThrow

Overrides CancelingEmployment.getHandlerOrThrow

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: Handler


getHandlers

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

Implementation of CommandBus

Inherited from HandlingMixin.getHandlers

Overrides CancelingEmployment.getHandlers

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


getHook

getHook(action: string, id: string): Hook | undefined

Implementation of Hookable

Inherited from HookableMixin.getHook

Overrides CreateEmployee.getHook

Parameters:

NameType
actionstring
idstring

Returns: Hook | undefined


getHookOrThrow

getHookOrThrow(action: string, id: string): Hook

Implementation of Hookable

Inherited from HookableMixin.getHookOrThrow

Overrides CreateEmployee.getHookOrThrow

Parameters:

NameType
actionstring
idstring

Returns: Hook


getHooks

getHooks(action: string): Mappings

Implementation of Hookable

Inherited from HookableMixin.getHooks

Overrides CreateEmployee.getHooks

Parameters:

NameType
actionstring

Returns: Mappings


getTypeByHandler

getTypeByHandler(handlerReference: Handler): any | undefined

Inherited from OneToOneHandlingMixin.getTypeByHandler

Overrides CancelingEmployment.getTypeByHandler

Parameters:

NameType
handlerReferenceHandler

Returns: any | undefined


handle

handle(command: Command): Promise‹any›

Overrides OneToOneHandlingMixin.handle

Handles command instance.

async

Parameters:

NameTypeDescription
commandCommandAn instance of Command type.

Returns: Promise‹any›

Any value returned as a Promise from handler.


handles

handles(): Map‹MessageTypeCommand›, Handler

Implementation of CommandBus

Inherited from HandlingMixin.handles

Overrides CancelingEmployment.handles

Returns: Map‹MessageTypeCommand›, Handler


hasAction

hasAction(action: string): boolean

Implementation of Hookable

Inherited from HookableMixin.hasAction

Overrides CreateEmployee.hasAction

Parameters:

NameType
actionstring

Returns: boolean


hasHandler

hasHandler(messageType: MessageTypeMessage›): boolean

Implementation of CommandBus

Inherited from HandlingMixin.hasHandler

Overrides CancelingEmployment.hasHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: boolean


hasHook

hasHook(action: string, id: string): boolean

Implementation of Hookable

Inherited from HookableMixin.hasHook

Overrides CreateEmployee.hasHook

Parameters:

NameType
actionstring
idstring

Returns: boolean


initialize

initialize(): void

Implementation of CommandBus

Inherited from OneToOneHandlingMixin.initialize

Overrides void

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


onSend

onSend(id: string, hook: Hook, shouldOverride?: boolean): void

Implementation of CommandBus

Registers onSend callback hook.

Parameters:

NameTypeDescription
idstringIdentifier under which onSend hook will be defined.
hookHookFunction that will be executed upon sending Command.
shouldOverride?booleanFlag indicating that hook should be overridden if exist.

Returns: void


overrideHandler

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

Implementation of CommandBus

Inherited from HandlingMixin.overrideHandler

Overrides CancelingEmployment.overrideHandler

Parameters:

NameType
messageTypeMessageTypeMessage
handlerHandler

Returns: void


overrideHook

overrideHook(action: string, id: string, hook: Hook): void

Implementation of Hookable

Inherited from HookableMixin.overrideHook

Overrides CreateEmployee.overrideHook

Parameters:

NameType
actionstring
idstring
hookHook

Returns: void


registerHandler

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

NameTypeDescription
commandTypeMessageTypeCommandA subclass of Command type.
handlerHandlerHandler function that will executed upon handling type.
shouldOverride?booleanFlag 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:

NameType
actionstring
idstring
hookHook
shouldOverride?boolean

Returns: void


removeHandler

removeHandler(messageType: MessageTypeMessage›): void

Implementation of CommandBus

Inherited from HandlingMixin.removeHandler

Overrides CancelingEmployment.removeHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: void


removeHook

removeHook(action: string, id: string): void

Implementation of Hookable

Inherited from HookableMixin.removeHook

Overrides CreateEmployee.removeHook

Parameters:

NameType
actionstring
idstring

Returns: void


send

send(command: Command): Promise‹any›

Implementation of CommandBus

alias handle

async

Parameters:

NameType
commandCommand

Returns: Promise‹any›


setHandleableTypes

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

Implementation of CommandBus

Inherited from HandlingMixin.setHandleableTypes

Overrides CancelingEmployment.setHandleableTypes

Parameters:

NameType
handleableTypesMessageTypeMessage› | MessageTypeMessage›[]

Returns: void


subscribes

subscribes(): Map‹MessageTypeEvent›, Handler

Implementation of CommandBus

Inherited from HandlingMixin.subscribes

Overrides CancelingEmployment.subscribes

Returns: Map‹MessageTypeEvent›, Handler