EventBusService
Can keep track of multiple subscribers to different events and run the subscribers when events happen. Events will run asynchronously.
Implements
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>enqueue_
Promise<void>Requiredmanager_
EntityManagerRequiredshouldEnqueuerRun
booleanRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Returns
EntityManager
EntityManagerRequiredeventBusModuleService_
Returns
Methods
atomicPhase_
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.
Parameters
work
(transactionManager: EntityManager) => Promise<TResult>Requiredthe transactional work to be done
isolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Potential error handler
Returns
Promise
Promise<TResult>Requiredthe result of the transactional work
emit
emit<T
>(data
): Promise
<void
| StagedJob
[]>
Calls all subscribers when an event occurs.
Parameters
The data to use to process the events
Returns
the jobs from our queue
emit<T
>(eventName
, data
, options?
): Promise
<void
| StagedJob
>
Calls all subscribers when an event occurs.
Parameters
eventName
stringRequiredthe name of the event to be process.
data
TRequiredthe data to send to the subscriber.
options
Record<string, unknown>options to add the job with
Returns
the job from our queue
enqueuer_
Returns
Promise
Promise<void>RequiredlistJobs
Parameters
Returns
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
booleanstartEnqueuer
Returns
void
voidstopEnqueuer
Returns
Promise
Promise<void>Requiredsubscribe
Adds a function to a list of event subscribers.
Parameters
event
string | symbolRequiredthe event that the subscriber will listen for.
the function to be called when a certain event happens. Subscribers must return a Promise.
context
SubscriberContextsubscriber context
Returns
this
unsubscribe
Removes function from the list of event subscribers.
Parameters
event
string | symbolRequiredthe event of the subcriber.
the function to be removed
subscriber context
Returns
this
withTransaction
Parameters
transactionManager
EntityManagerReturns
Was this section helpful?