EventHandlingMixin
Hierarchy
OneToManyHandlingMixin
↳ EventHandlingMixin
Implements
- Controller
- Publisher
- Controller
- Publisher
Index
Constructors
Properties
Methods
- ensureHandleability
- getHandleableTypes
- getHandled
- getHandledCommands
- getHandledEvents
- getHandledMessages
- getHandledTypes
- getHandledTypesNames
- getHandler
- getHandlerOrThrow
- getHandlers
- getSubscribedEvents
- getTypeByHandler
- handle
- handles
- hasHandler
- initialize
- isHandleabe
- on
- overrideHandler
- publish
- registerEventHandler
- registerHandler
- removeHandler
- setHandleableTypes
- subscribeTo
- subscribes
Constructors
constructor
+ new EventHandlingMixin(): EventHandlingMixin
Inherited from HandlingMixin.constructor
Overrides void
Returns: EventHandlingMixin
Properties
eventBus
• eventBus: EventBus
Methods
ensureHandleability
▸ ensureHandleability(messageType
: MessageType‹Message›, handleableTypes?
: MessageType‹Message› | MessageType‹Message›[]): boolean
Implementation of Publisher
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 Publisher
Inherited from HandlingMixin.getHandleableTypes
Overrides CancelingEmployment.getHandleableTypes
Returns: MessageType‹Message›[]
getHandled
▸ getHandled(messageType
: MessageType‹Message›): MessageType‹Message›[]
Implementation of Publisher
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 Publisher
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 Publisher
Inherited from OneToManyHandlingMixin.getHandler
Overrides void
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: Handler[] | undefined
getHandlerOrThrow
▸ getHandlerOrThrow(messageType
: MessageType‹Message›): Handler[]
Implementation of Publisher
Inherited from OneToManyHandlingMixin.getHandlerOrThrow
Overrides void
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: Handler[]
getHandlers
▸ getHandlers(): Map‹MessageType‹Message›, Handler | Handler[]›
Implementation of Publisher
Inherited from HandlingMixin.getHandlers
Overrides CancelingEmployment.getHandlers
Returns: Map‹MessageType‹Message›, Handler | Handler[]›
getSubscribedEvents
▸ getSubscribedEvents(): MessageType‹Event›[]
alias
getHandledEvents
Returns: MessageType‹Event›[]
getTypeByHandler
▸ getTypeByHandler(handlerReference
: Handler): any | undefined
Inherited from OneToManyHandlingMixin.getTypeByHandler
Overrides void
Parameters:
Name | Type |
---|---|
handlerReference | Handler |
Returns: any | undefined
handle
▸ handle(message
: Message, execution?
: Execution): Promise‹void›
Implementation of Publisher
Inherited from OneToManyHandlingMixin.handle
Overrides void
Parameters:
Name | Type |
---|---|
message | Message |
execution? | Execution |
Returns: Promise‹void›
handles
▸ handles(): Map‹MessageType‹Command›, Handler›
Implementation of Publisher
Inherited from HandlingMixin.handles
Overrides CancelingEmployment.handles
Returns: Map‹MessageType‹Command›, Handler›
hasHandler
▸ hasHandler(messageType
: MessageType‹Message›): boolean
Implementation of Publisher
Inherited from HandlingMixin.hasHandler
Overrides CancelingEmployment.hasHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
Returns: boolean
initialize
▸ initialize(): void
Implementation of Publisher
Overrides OneToManyHandlingMixin.initialize
Initializes EventHandlingMixin.
remarks
By defining handler mappings on metadata with annotations: @subscribe
and resolving those mapping with 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
on
▸ on(event
: Event): Promise‹void›
alias
handle
async
Parameters:
Name | Type | Description |
---|---|---|
event | Event | Instance implementing Event interface. |
Returns: Promise‹void›
overrideHandler
▸ overrideHandler(messageType
: MessageType‹Message›, handler
: Handler): void
Implementation of Publisher
Inherited from HandlingMixin.overrideHandler
Overrides CancelingEmployment.overrideHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handler | Handler |
Returns: void
publish
▸ publish(event
: Event): Promise‹void›
Implementation of Publisher
Publishes(handles) event instance on event bus.
async
Parameters:
Name | Type | Description |
---|---|---|
event | Event | Instance implementing Event interface. |
Returns: Promise‹void›
registerEventHandler
▸ registerEventHandler(eventType
: MessageType‹Event›, handler
: Handler, shouldOverride?
: boolean): void
Registers event handler and subscribes to that event on event bus.
throws
{UnhandleableTypeError}
Thrown if the type argument is not one of handleable types.
throws
{InvalidHandlerError}
Thrown if the handler argument is not a function.
Parameters:
Name | Type | Description |
---|---|---|
eventType | MessageType‹Event› | A Event 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 Publisher
Inherited from OneToManyHandlingMixin.registerHandler
Overrides HandlingMixin.registerHandler
Parameters:
Name | Type |
---|---|
messageType | MessageType‹Message› |
handler | Handler |
shouldOverride? | boolean |
Returns: void
removeHandler
▸ removeHandler(messageType
: MessageType‹Message›): void
Implementation of Publisher
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 Publisher
Inherited from HandlingMixin.setHandleableTypes
Overrides CancelingEmployment.setHandleableTypes
Parameters:
Name | Type |
---|---|
handleableTypes | MessageType‹Message› | MessageType‹Message›[] |
Returns: void
subscribeTo
▸ subscribeTo(eventType
: MessageType‹Event›, handler
: Handler, shouldOverride?
: boolean): void
Subscribes to event(registers handler).
alias
registerEventHandler
Parameters:
Name | Type |
---|---|
eventType | MessageType‹Event› |
handler | Handler |
shouldOverride? | boolean |
Returns: void
subscribes
▸ subscribes(): Map‹MessageType‹Event›, Handler›
Implementation of Publisher
Inherited from HandlingMixin.subscribes
Overrides CancelingEmployment.subscribes
Returns: Map‹MessageType‹Event›, Handler›