HandlingMixin
Hierarchy
HandlingMixin
Index
Constructors
Methods
- ensureHandleability
- getHandleableTypes
- getHandled
- getHandledCommands
- getHandledEvents
- getHandledMessages
- getHandledTypes
- getHandledTypesNames
- getHandlers
- handles
- hasHandler
- isHandleabe
- overrideHandler
- registerHandler
- removeHandler
- setHandleableTypes
- subscribes
Constructors
constructor
+ new HandlingMixin(): HandlingMixin
Creates an instance of HandlingMixin. Creates an instance of HandlingMixin.
Returns: HandlingMixin
Methods
ensureHandleability
▸ ensureHandleability(messageType
: MessageType‹Message›, handleableTypes?
: MessageType‹Message› | MessageType‹Message›[]): boolean
Ensures that provided type can be handled by verifying it against handleable types.
throws
{UnhandleableTypeError}
Thrown if message type is not one of handleable types.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
handleableTypes? | MessageType‹Message› | MessageType‹Message›[] | Optional handleable types to be verified against on runtime. |
Returns: boolean
Returns true if type
is handleable, else false
.
getHandleableTypes
▸ getHandleableTypes(): MessageType‹Message›[]
Returns handleable message types.
Returns: MessageType‹Message›[]
Returns handleable message types as a list with message types.
getHandled
▸ getHandled(messageType
: MessageType‹Message›): MessageType‹Message›[]
Returns all message types that matches evaluated one by equal constructor or subclassing.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: MessageType‹Message›[]
List of all handled types matching evaluated one.
getHandledCommands
▸ getHandledCommands(): MessageType‹Command›[]
Returns all commands that can be handled.
Returns: MessageType‹Command›[]
List of all handled types matching Command
.
getHandledEvents
▸ getHandledEvents(): MessageType‹Event›[]
Returns all commands that can be handled.
Returns: MessageType‹Event›[]
List of all handled types matching Event
.
getHandledMessages
▸ getHandledMessages(): MessageType‹Message›[]
Returns all messages that can be handled.
Returns: MessageType‹Message›[]
List of all handled types matching Message
.
getHandledTypes
▸ getHandledTypes(): MessageType‹Message›[]
Returns all handled message types.
Returns: MessageType‹Message›[]
List of all handled message types.
getHandledTypesNames
▸ getHandledTypesNames(): TypeName[]
Returns all type names that can be handled.
Returns: TypeName[]
List of all handled type names
getHandlers
▸ getHandlers(): Map‹MessageType‹Message›, Handler | Handler[]›
Returns all available handler mappings.
Returns: Map‹MessageType‹Message›, Handler | Handler[]›
Returns mappings of all available handlers by message type: handler(s) relation.
handles
▸ handles(): Map‹MessageType‹Command›, Handler›
Returns all handled Command
mappings.
example
Returns: Map‹MessageType‹Command›, Handler›
Returns all handled Command
(s) defined with @handle
annotation
or allows developer to define manually handlers.
hasHandler
▸ hasHandler(messageType
: MessageType‹Message›): boolean
Evaluates if handler for message type is registered.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: boolean
Returns true
if handler for message type is registered, else false
.
isHandleabe
▸ isHandleabe(messageType
: MessageType‹Message›, handleableTypes?
: MessageType‹Message› | MessageType‹Message›[]): boolean
Evaluates if type can be handled.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
handleableTypes? | MessageType‹Message› | MessageType‹Message›[] | Optional handleable types to be verified against on runtime. |
Returns: boolean
Returns true
if message type can be handled, else false
.
overrideHandler
▸ overrideHandler(messageType
: MessageType‹Message›, handler
: Handler): void
Overrides already existing handler for message type.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
handler | Handler | Handler function that will executed upon handling message type. |
Returns: void
registerHandler
▸ registerHandler(_messageType
: MessageType‹Message›, _handler
: Handler, _shouldOverride?
: boolean): void
[!] Placeholder for registering handler for message type.
Parameters:
Name | Type |
---|---|
_messageType | MessageType‹Message› |
_handler | Handler |
_shouldOverride? | boolean |
Returns: void
removeHandler
▸ removeHandler(messageType
: MessageType‹Message›): void
Removes handler by type.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: void
setHandleableTypes
▸ setHandleableTypes(handleableTypes
: MessageType‹Message› | MessageType‹Message›[]): void
Sets the only allowed handleable message types.
Parameters:
Name | Type | Description |
---|---|---|
handleableTypes | MessageType‹Message› | MessageType‹Message›[] | List of allowed types for handling. |
Returns: void
subscribes
▸ subscribes(): Map‹MessageType‹Event›, Handler›
Returns all handled Event
mappings.
example
Returns: Map‹MessageType‹Event›, Handler›
Returns all handled Events
(s) defined with @subscribe
annotation
or allows developer to define manually handlers.