Skip to content

DI Bag API / index / LifetimeObligation

Type Alias: LifetimeObligation ​

ts
type LifetimeObligation = {
    readonly kind: 'singleton-reach';
    readonly singleton: PropertyKey;
    readonly reach: Reach;
} | {
    readonly kind: 'export-reach';
    readonly export: PropertyKey;
    readonly reach: Reach;
} | {
    readonly kind: 'contribution-reach';
    readonly group: symbol;
    readonly policy: 'singleton' | 'transient';
    readonly reach: Reach;
};

Defined in: lifetime-types.ts:26

A compact seal-time lifetime record that replaces a module's private providers: singleton-reach names a private strict singleton, export-reach an export the host checks as a singleton or walks through as a transient or alias, and contribution-reach a sealed contribution group that is checked as a singleton or walked by collecting singleton providers. Each record carries one reach.

See ​

https://dany-fedorov.github.io/di-bag/agent/errors.html#singleton-captures-scoped

Ordinary services. Checked composition. Explicit ownership.