OneToManyHandlingMixin
Hierarchy
HandlingMixin
↳ OneToManyHandlingMixin
Implements
- Controller
- Controller
Index
Constructors
Methods
- ensureHandleability
- getHandleableTypes
- getHandled
- getHandledCommands
- getHandledEvents
- getHandledMessages
- getHandledTypes
- getHandledTypesNames
- getHandler
- getHandlerOrThrow
- getHandlers
- getTypeByHandler
- handle
- handles
- hasHandler
- initialize
- isHandleabe
- overrideHandler
- registerHandler
- removeHandler
- setHandleableTypes
- subscribes
Constructors
constructor
+ new OneToManyHandlingMixin(): OneToManyHandlingMixin
Inherited from HandlingMixin.constructor
Overrides void
Returns: OneToManyHandlingMixin
Methods
ensureHandleability
▸ ensureHandleability(messageType
: MessageType‹Message›, handleableTypes?
: MessageType‹Message› | MessageType‹Message›[]): boolean
Implementation of Controller
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 Controller
Inherited from HandlingMixin.getHandleableTypes
Overrides CancelingEmployment.getHandleableTypes
Returns: MessageType‹Message›[]
getHandled
▸ getHandled(messageType
: MessageType‹Message›): MessageType‹Message›[]
Implementation of Controller
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 Controller
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 Controller
Returns handlers for message type.
throws
{InvalidMessageableType}
Thrown if the message type argument is not implementing Messageable
interface.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: Handler[] | undefined
List with handlers as a functions if found, else undefined
.
getHandlerOrThrow
▸ getHandlerOrThrow(messageType
: MessageType‹Message›): 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:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: Handler[]
List with handlers as a functions if found, else throws.
getHandlers
▸ getHandlers(): Map‹MessageType‹Message›, Handler | Handler[]›
Implementation of Controller
Inherited from HandlingMixin.getHandlers
Overrides CancelingEmployment.getHandlers
Returns: Map‹MessageType‹Message›, Handler | Handler[]›
getTypeByHandler
▸ getTypeByHandler(handlerReference
: Handler): any | undefined
Resolves message type by handler reference.
Parameters:
Name | Type | Description |
---|---|---|
handlerReference | Handler | Reference 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:
Name | Type | Description |
---|---|---|
message | Message | Type implementing Messageable interface. |
execution? | Execution | - |
Returns: Promise‹void›
handles
▸ handles(): Map‹MessageType‹Command›, Handler›
Implementation of Controller
Inherited from HandlingMixin.handles
Overrides CancelingEmployment.handles
Returns: Map‹MessageType‹Command›, Handler›
hasHandler
▸ hasHandler(messageType
: MessageType‹Message›): boolean
Implementation of Controller
Inherited from HandlingMixin.hasHandler
Overrides CancelingEmployment.hasHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
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
: 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 Controller
Inherited from HandlingMixin.overrideHandler
Overrides CancelingEmployment.overrideHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handler | Handler |
Returns: void
registerHandler
▸ registerHandler(messageType
: MessageType‹Message›, 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
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
handler | Handler | Handler function that will executed upon handling message type. |
shouldOverride? | boolean | Flag indicating that handler should be overridden if exist. |
Returns: void
removeHandler
▸ removeHandler(messageType
: MessageType‹Message›): void
Implementation of Controller
Inherited from HandlingMixin.removeHandler
Overrides CancelingEmployment.removeHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: void
setHandleableTypes
▸ setHandleableTypes(handleableTypes
: MessageType‹Message› | MessageType‹Message›[]): void
Implementation of Controller
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 Controller
Inherited from HandlingMixin.subscribes
Overrides CancelingEmployment.subscribes
Returns: Map‹MessageType‹Event›, Handler›