class EventBus<EventBase extends IEvent = IEvent> extends ObservableBus implements IEventBus, OnModuleDestroy {
protected eventIdProvider: EventIdProvider<EventBase>
protected subscriptions: Subscription[]
publisher: IEventPublisher<EventBase>
onModuleDestroy()
publish<TEvent extends EventBase, TContext = unknown>(event: TEvent, dispatcherOrAsyncContext?: AsyncContext | TContext, asyncContext?: AsyncContext)
publishAll<TEvent extends EventBase, TContext = unknown>(events: TEvent[], dispatcherOrAsyncContext?: AsyncContext | TContext, asyncContext?: AsyncContext)
bind(handler: InstanceWrapper<IEventHandler<EventBase>>, id: string)
registerSagas(wrappers: InstanceWrapper<object>[] = [])
register(handlers: InstanceWrapper<IEventHandler<EventBase>>[] = [])
protected registerHandler(handler: InstanceWrapper<IEventHandler<EventBase>>)
protected ofEventId(id: string)
protected registerSaga(saga: ISaga<EventBase, ICommand>)
constructor()
protected _subject$: Subject<T>
subject$
}
Properties
Property |
Description |
protected eventIdProvider: EventIdProvider<EventBase>
|
|
protected subscriptions: Subscription[]
|
Read-only.
|
publisher: IEventPublisher<EventBase>
|
Returns the publisher.
Default publisher is DefaultPubSub (in memory).
|
Methods
onModuleDestroy()
|
onModuleDestroy()
Parameters
There are no parameters.
|
publish()
|
Publishes an event.
|
Overload #1
publish<TEvent extends EventBase>(event: TEvent): any
Parameters
Option |
Type |
Description |
event
|
TEvent |
The event to publish.
|
Returns
any
Overload #2
publish<TEvent extends EventBase>(event: TEvent, asyncContext: AsyncContext): any
Parameters
Option |
Type |
Description |
event
|
TEvent |
The event to publish.
|
asyncContext
|
AsyncContext |
Async context
|
Returns
any
Overload #3
publish<TEvent extends EventBase, TContext = unknown>(event: TEvent, dispatcherContext: TContext): any
Parameters
Option |
Type |
Description |
event
|
TEvent |
The event to publish.
|
dispatcherContext
|
TContext |
Dispatcher context
|
Returns
any
Overload #4
publish<TEvent extends EventBase, TContext = unknown>(event: TEvent, dispatcherContext: TContext, asyncContext: AsyncContext): any
Parameters
Option |
Type |
Description |
event
|
TEvent |
The event to publish.
|
dispatcherContext
|
TContext |
Dispatcher context
|
asyncContext
|
AsyncContext |
Async context
|
Returns
any
|
publishAll()
|
Publishes multiple events.
|
Overload #1
publishAll<TEvent extends EventBase>(events: TEvent[]): any
Parameters
Option |
Type |
Description |
events
|
TEvent[] |
The events to publish.
|
Returns
any
Overload #2
publishAll<TEvent extends EventBase>(events: TEvent[], asyncContext: AsyncContext): any
Parameters
Option |
Type |
Description |
events
|
TEvent[] |
The events to publish.
|
asyncContext
|
AsyncContext |
Async context
|
Returns
any
Overload #3
publishAll<TEvent extends EventBase, TContext = unknown>(events: TEvent[], dispatcherContext: TContext): any
Parameters
Option |
Type |
Description |
events
|
TEvent[] |
The events to publish.
|
dispatcherContext
|
TContext |
Dispatcher context
|
Returns
any
Overload #4
publishAll<TEvent extends EventBase, TContext = unknown>(events: TEvent[], dispatcherContext: TContext, asyncContext: AsyncContext): any
Parameters
Option |
Type |
Description |
events
|
TEvent[] |
The events to publish.
|
dispatcherContext
|
TContext |
Dispatcher context
|
asyncContext
|
AsyncContext |
Async context
|
Returns
any
|
bind()
|
bind(handler: InstanceWrapper<IEventHandler<EventBase>>, id: string)
Parameters
Option |
Type |
Description |
handler
|
InstanceWrapper> |
|
id
|
string |
|
|
registerSagas()
|
registerSagas(wrappers: InstanceWrapper<object>[] = [])
Parameters
Option |
Type |
Description |
wrappers
|
InstanceWrapper |
Optional. Default is [] .
|
|
register()
|
register(handlers: InstanceWrapper<IEventHandler<EventBase>>[] = [])
Parameters
Option |
Type |
Description |
handlers
|
InstanceWrapper>[] |
Optional. Default is [] .
|
|
registerHandler()
|
protected registerHandler(handler: InstanceWrapper<IEventHandler<EventBase>>)
Parameters
Option |
Type |
Description |
handler
|
InstanceWrapper> |
|
|
ofEventId()
|
protected ofEventId(id: string)
Parameters
Option |
Type |
Description |
id
|
string |
|
|
registerSaga()
|
protected registerSaga(saga: ISaga<EventBase, ICommand>)
Parameters
Option |
Type |
Description |
saga
|
ISaga |
|
|