ServiceContext type
Home > @rimitive/core > ServiceContext
ServiceContext type
Section titled “ServiceContext type”Context provided to modules for lifecycle management.
Passed to init, destroy, and instrument hooks.
Signature:
export type ServiceContext = { destroy(cleanup: () => void): void; readonly isDestroyed: boolean;};Example
Section titled “Example”const MyModule = defineModule({ name: 'myModule', create: () => createImpl(), init(ctx) { // Register cleanup ctx.destroy(() => cleanup()); },});