OneToManyHandlingMixin

Hierarchy

Implements

Index

Constructors

Methods

Constructors

constructor

+ new OneToManyHandlingMixin(): OneToManyHandlingMixin

Inherited from HandlingMixin.constructor

Overrides void

Returns: OneToManyHandlingMixin

Methods

ensureHandleability

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

Implementation of Controller

Inherited from HandlingMixin.ensureHandleability

Overrides CancelingEmployment.ensureHandleability

Parameters:

NameType
messageTypeMessageTypeMessage
handleableTypes?MessageTypeMessage› | MessageTypeMessage›[]

Returns: boolean


getHandleableTypes

getHandleableTypes(): MessageTypeMessage›[]

Implementation of Controller

Inherited from HandlingMixin.getHandleableTypes

Overrides CancelingEmployment.getHandleableTypes

Returns: MessageTypeMessage›[]


getHandled

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

Implementation of Controller

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 Controller

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 Controller

Returns handlers for message type.

throws {InvalidMessageableType} Thrown if the message type argument is not implementing Messageable interface.

Parameters:

NameTypeDescription
messageTypeMessageTypeMessageType implementing MessageableType interface.

Returns: Handler[] | undefined

List with handlers as a functions if found, else undefined.


getHandlerOrThrow

getHandlerOrThrow(messageType: MessageTypeMessage›): Handler[]

Implementation of Controller

Return handlers for message type or throws error if not found.

throws {HandlerNotFoundError} Thrown if handler for message type is not found.

Parameters:

NameTypeDescription
messageTypeMessageTypeMessageType implementing MessageableType interface.

Returns: Handler[]

List with handlers as a functions if found, else throws.


getHandlers

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

Implementation of Controller

Inherited from HandlingMixin.getHandlers

Overrides CancelingEmployment.getHandlers

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


getTypeByHandler

getTypeByHandler(handlerReference: Handler): any | undefined

Resolves message type by handler reference.

Parameters:

NameTypeDescription
handlerReferenceHandlerReference to handler function.

Returns: any | undefined

Message type if handler is matching one of handlers on class, else undefined.


handle

handle(message: Message, execution?: Execution): Promise‹void›

Implementation of Controller

Handles message type instance sequentially.

async

Parameters:

NameTypeDescription
messageMessageType implementing Messageable interface.
execution?Execution-

Returns: Promise‹void›


handles

handles(): Map‹MessageTypeCommand›, Handler

Implementation of Controller

Inherited from HandlingMixin.handles

Overrides CancelingEmployment.handles

Returns: Map‹MessageTypeCommand›, Handler


hasHandler

hasHandler(messageType: MessageTypeMessage›): boolean

Implementation of Controller

Inherited from HandlingMixin.hasHandler

Overrides CancelingEmployment.hasHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: boolean


initialize

initialize(): void

Implementation of Controller

Initializes OneToManyHandlingMixin.

remarks By defining handler mappings on metadata with annotations: @handle, @subscribe and resolving those mapping with handles, subscribes 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 Controller

Inherited from HandlingMixin.overrideHandler

Overrides CancelingEmployment.overrideHandler

Parameters:

NameType
messageTypeMessageTypeMessage
handlerHandler

Returns: void


registerHandler

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

Implementation of Controller

Overrides HandlingMixin.registerHandler

Registers handler for message type.

throws {UnhandleableTypeError} Thrown if the type argument is not one of handleable types.

throws {InvalidHandlerError} Thrown if the handler argument is not a function.

example

@define('MyEvent')
class MyEvent extends Event<MyEvent> {
key: string;
}
@define('MyOtherEvent')
class MyOtherEvent extends Event<MyOtherEvent> {
key: string;
}
class MyClass extends OneToManyHandlingMixin {
MyEvent(event: MyEvent): void {
// ...
}
@handles()
MyOtherEvent(event: MyOtherEvent): void {
// ...
}
}
const myClass = new MyClass();
myClass.registerHandler(MyEvent, myClass.MyEvent);

Parameters:

NameTypeDescription
messageTypeMessageTypeMessageType implementing MessageableType interface.
handlerHandlerHandler function that will executed upon handling message type.
shouldOverride?booleanFlag indicating that handler should be overridden if exist.

Returns: void


removeHandler

removeHandler(messageType: MessageTypeMessage›): void

Implementation of Controller

Inherited from HandlingMixin.removeHandler

Overrides CancelingEmployment.removeHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: void


setHandleableTypes

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

Implementation of Controller

Inherited from HandlingMixin.setHandleableTypes

Overrides CancelingEmployment.setHandleableTypes

Parameters:

NameType
handleableTypesMessageTypeMessage› | MessageTypeMessage›[]

Returns: void


subscribes

subscribes(): Map‹MessageTypeEvent›, Handler

Implementation of Controller

Inherited from HandlingMixin.subscribes

Overrides CancelingEmployment.subscribes

Returns: Map‹MessageTypeEvent›, Handler