Documents injecute 1.x · Migrating from 0.x
Skip to content

Variable: lifecycle ​

const lifecycle: Lifecycle<"init" | "start" | "ready">

Defined in: src/utils/lifecycle.ts:330

The default stages, in order: init (wire contributions, migrate, warm up), start (begin accepting work: listen, start consumers) and ready (announce: readiness probe, service discovery). Stopping undoes them in reverse.

Example ​

ts
const addPayments = (c: ServiceRegistry<{ bus: Bus }>) =>
  c
    .addSingleton('consumer', PaymentConsumer, ['bus'])
    .addSingleton(lifecycle.start('consumer'), (consumer) => {
      consumer.start();
      return () => consumer.stop();
    }, ['consumer']);

Released under the MIT License.