EventBus

  
class EventBus<EventBase extends IEvent = IEvent> extends ObservableBus implements IEventBus, OnModuleDestroy {
  protected getEventId: (event: EventBase) => string | null
  protected subscriptions: Subscription[]
  publisher: IEventPublisher<EventBase>
  onModuleDestroy()
  publish<T extends EventBase>(event: T)
  publishAll<T extends EventBase>(events: T[])
  bind(handler: IEventHandler<EventBase>, id: string)
  registerSagas(types: Type<unknown>[] = [])
  register(handlers: Type<IEventHandler<EventBase>>[] = [])
  protected registerHandler(handler: Type<IEventHandler<EventBase>>)
  protected ofEventId(id: string)
  protected registerSaga(saga: ISaga<EventBase, ICommand>)

  // inherited from cqrs/src/ObservableBus
  constructor()
  protected _subject$: Subject<T>
  subject$
}

Properties

Property Description
protected getEventId: (event: EventBase) => string | null
protected subscriptions: Subscription[] Read-only.
publisher: IEventPublisher<EventBase>

Methods

onModuleDestroy()


onModuleDestroy()

Parameters

There are no parameters.

publish()


publish<T extends EventBase>(event: T)

Parameters

Option Type Description
event T

publishAll()


publishAll<T extends EventBase>(events: T[])

Parameters

Option Type Description
events T[]

bind()


bind(handler: IEventHandler<EventBase>, id: string)

Parameters

Option Type Description
handler IEventHandler
id string

registerSagas()


registerSagas(types: Type<unknown>[] = [])

Parameters

Option Type Description
types Type[]

Optional. Default is [].

register()


register(handlers: Type<IEventHandler<EventBase>>[] = [])

Parameters

Option Type Description
handlers Type>[]

Optional. Default is [].

registerHandler()


protected registerHandler(handler: Type<IEventHandler<EventBase>>)

Parameters

Option Type Description
handler Type>

ofEventId()


protected ofEventId(id: string)

Parameters

Option Type Description
id string

registerSaga()


protected registerSaga(saga: ISaga<EventBase, ICommand>)

Parameters

Option Type Description
saga ISaga