EventBusService
internal.internal.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_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
emit
emit<T
>(data
): Promise
<void
| StagedJob
[]>
Calls all subscribers when an event occurs.
T
objectRequiredParameters
Returns
Promise
<void
| StagedJob
[]>
the jobs from our queue
Implementation of
emit<T
>(eventName
, data
, options?
): Promise
<void
| StagedJob
>
Calls all subscribers when an event occurs.
T
objectRequiredParameters
eventName
stringRequireddata
TRequiredoptions
Record<string, unknown>Returns
Promise
<void
| StagedJob
>
the job from our queue
Implementation of
EventBusTypes.IEventBusService.emit
enqueuer_
enqueuer_(): Promise
<void
>
Returns
Promise
<void
>
Promise
Promise<void>RequiredlistJobs
Protected
listJobs(listConfig
): Promise
<never
[] | StagedJob
[]>
Parameters
Returns
Promise
<never
[] | StagedJob
[]>
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
startEnqueuer
startEnqueuer(): void
Returns
void
void
voidstopEnqueuer
stopEnqueuer(): Promise
<void
>
Returns
Promise
<void
>
Promise
Promise<void>Requiredsubscribe
subscribe(event
, subscriber
, context?
): EventBusService
Adds a function to a list of event subscribers.
Parameters
event
string | symbolRequiredcontext
SubscriberContextReturns
Implementation of
unsubscribe
unsubscribe(event
, subscriber
, context
): EventBusService
Removes function from the list of event subscribers.
Parameters
event
string | symbolRequiredReturns
Implementation of
withTransaction
withTransaction(transactionManager?
): EventBusService
Parameters
transactionManager
EntityManagerReturns
Implementation of
IEventBusService.withTransaction