Skip to content

ServiceContext type

Home > @rimitive/core > ServiceContext

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;
};
const MyModule = defineModule({
name: 'myModule',
create: () => createImpl(),
init(ctx) {
// Register cleanup
ctx.destroy(() => cleanup());
},
});