export interface IPubSubBroker<TEvents extends Record<string, any>> extends IBaseBroker<TEvents>, AsyncEventEmitter<ToEventMap<TEvents>>
export interface IPubSubBroker<TEvents extends Record<string, any>> extends IBaseBroker<TEvents>, AsyncEventEmitter<ToEventMap<TEvents>>
No summary provided.
Extends
IBaseBroker<TEvents>AsyncEventEmitter<ToEventMap<TEvents>>Name | Constraints | Optional | Default | Description |
---|---|---|---|---|
TEvents | Record<string, any> | No | None |
publish(event, data)
:
Promise<void>
Publishes an event
Name | Type | Optional | Description |
---|---|---|---|
event | T | No | None |
data | TEvents[T] | No | None |
subscribe(group, events)
:
Promise<void>
Subscribes to the given events, grouping them by the given group name
Name | Type | Optional | Description |
---|---|---|---|
group | string | No | None |
events | (keyof TEvents)[] | No | None |
unsubscribe(group, events)
:
Promise<void>
Unsubscribes from the given events - it's required to pass the same group name as when subscribing for proper cleanup
Name | Type | Optional | Description |
---|---|---|---|
group | string | No | None |
events | (keyof TEvents)[] | No | None |