whenLeader
Function: whenLeader()
whenLeader(
fn,deregisteredFn?): () =>void
Defined in: packages/core/src/services/cluster.service.ts:461
Run fn whenever this instance becomes the leader of the cluster, and deregisteredFn when it stops leading
Called while the Core initializes, before a cluster service exists (from a constructor, resolve() or init() of
a service configured before it), the registration waits for that cluster service to be resolved, or for the end of
the initialization to fall back to the local cluster.
Parameters
fn
called when this instance becomes the leader
deregisteredFn?
called when it loses the leadership or shuts down
Returns
a function removing the registration
() => void
See
Cluster.whenLeader