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

Type Alias: LifecycleHook ​

LifecycleHook = void | LifecycleUndo | PromiseLike<void | LifecycleUndo>

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

What a lifecycle hook produces: nothing, or a function that undoes it (or a promise of either). The undo function receives the signal passed to running.stop(), aborted when stopping takes too long.

Example ​

ts
app.addSingleton(lifecycle.start('server'), (server): LifecycleHook => {
  server.listen(8080);
  return () => server.close();
}, ['server']);

Released under the MIT License.