Skip to content

DI Bag API / index / FactoryContext

Interface: FactoryContext ​

Defined in: acquisition-context.ts:30

Cooperative cancellation and acquisition-local ownership supplied to a context-aware factory.

See ​

https://dany-fedorov.github.io/di-bag/guides/tutorial.html#make-selected-services-ready

Properties ​

abortSignal ​

ts
readonly abortSignal: AbortSignal;

Defined in: acquisition-context.ts:32

Aborted when the acquisition's owning container begins closing.

Methods ​

pushDisposer() ​

ts
pushDisposer(this: void, disposer: (this: void, disposerContext: DisposerContext) => void | Promise<void>): void;

Defined in: acquisition-context.ts:38

Own a resource acquired during this factory call; pushed disposers run once in reverse order. Pass the release callback itself, such as () => socket.close(), rather than calling it here.

Parameters ​

ParameterDescription
this-
disposerReleases the acquired resource when the factory fails or the container closes.

Ordinary services. Checked composition. Explicit ownership.