Interface: IMessageBus
IMessageBus defines the contract for a message bus, handling receiver subscription/unsubcription, message publishing, and message dispatching.
Implemented by
Table of contents
Properties
Properties
Dispatch
• Dispatch: () => void
Dispatch processes the current message bus queue and forwards the messages to the subscribers who have subscribed to each message type.
Type declaration:
▸ (): void
Returns: void
DispatchUntilEmpty
• DispatchUntilEmpty: () => void
DispatchUntilEmpty repeatedly dispatches until the message queue is empty, used to make sure everything is processed, e.g. if there is a message that causes a new message to be added, it will ensure that all recursive messages are processed.
Type declaration:
▸ (): void
Returns: void
Publish
• Publish: (message
: IMessage) => void
Publish adds a message to the message bus queue to be dispatched.
param
The message to send
Type declaration:
▸ (message
: IMessage): void
Parameters:
Name | Type |
---|---|
message |
IMessage |
Returns: void
Subscribe
• Subscribe: (subscriber
: ISubscriber, types
: string | string[]) => void
Subscribe subscibes a subscriber to a particular message type or types.
param
The subscriber to the message type(s)
param
The message type(s) to subscribe to
Type declaration:
▸ (subscriber
: ISubscriber, types
: string | string[]): void
Parameters:
Name | Type |
---|---|
subscriber |
ISubscriber |
types |
string | string[] |
Returns: void
Unsubscribe
• Unsubscribe: (subscriber
: ISubscriber, types
: string | string[]) => void
Unsubscribe unsubscribes a subscriber from a specific message type or types.
param
The subscriber to unsubscribe
param
The message type(s) to unsubscribe from
Type declaration:
▸ (subscriber
: ISubscriber, types
: string | string[]): void
Parameters:
Name | Type |
---|---|
subscriber |
ISubscriber |
types |
string | string[] |
Returns: void
UnsubscribeAll
• UnsubscribeAll: (subscriber
: ISubscriber) => void
UnsubscribeAll unsubscribes a Subscriber from all messages.
param
The subscriber to unsubscribe
Type declaration:
▸ (subscriber
: ISubscriber): void
Parameters:
Name | Type |
---|---|
subscriber |
ISubscriber |
Returns: void