EventBusService
Can keep track of multiple subscribers to different events and run the subscribers when events happen. Events will run asynchronously.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredisSingleton
booleanRequiredDefault: true
Properties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredshouldEnqueuerRun
booleanRequiredenqueue_
Promise<void>Required__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredeventBusModuleService_
Returns
IEventBusModuleService
objectRequiredMethods
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
Type Parameters
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>RequiredwithTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredsubscribe
Adds a function to a list of event subscribers.
Parameters
event
string | symbolRequiredcontext
SubscriberContextReturns
this
thisRequiredunsubscribe
Removes function from the list of event subscribers.
Parameters
event
string | symbolRequiredReturns
this
thisRequiredemit
**emit**<TypeParameter T>(data): Promise<void \| [StagedJob](/references/entities/classes/StagedJob)[]>
Calls all subscribers when an event occurs.
Type Parameters
T
objectRequiredParameters
Returns
**emit**<TypeParameter T>(data): Promise<void \| [StagedJob](/references/entities/classes/StagedJob)[]>
Type Parameters
T
objectRequiredParameters
Returns
**emit**<TypeParameter T>(eventName, data, options?): Promise<void \| [StagedJob](/references/entities/classes/StagedJob)>
Calls all subscribers when an event occurs.
Type Parameters
T
objectRequiredParameters
eventName
stringRequireddata
TRequiredoptions
Record<string, unknown>Returns
startEnqueuer
Returns
void
voidRequiredstopEnqueuer
Returns
Promise
Promise<void>Requiredenqueuer_
Returns
Promise
Promise<void>Required