Interface: FactoryBindingDescriptor<T>
Defined in: src/wirestate-core/binding/binding.ts:158
Describes a token-bound value produced by a factory function.
Remarks
Use a factory binding when a dependency should be created on first resolution, should read other container bindings while it is created, or should create a fresh value for each resolution with Transient scope. Singleton factories are cached after the first resolution. Factory results are not service instances, so service lifecycle decorators and messaging handlers are not wired for the returned value.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
T | unknown | Value returned by the factory. |
Properties
factory
readonly factory: (container: Container) => NoInfer<T>;Defined in: src/wirestate-core/binding/binding.ts:176
Creates the value for this token.
Parameters
| Parameter | Type |
|---|---|
container | Container |
Returns
NoInfer<T>
Remarks
Receives the current container and runs inside the injection context, so both current.get(...) and inject(...) can read other bindings.
scope?
readonly optional scope?: "Singleton" | "Transient";Defined in: src/wirestate-core/binding/binding.ts:185
Lifetime scope for factory results.
Remarks
Defaults to Singleton, which calls the factory once and reuses the result. Transient calls the factory on every resolution and does not cache the result.
token
readonly token: ServiceToken<T>;Defined in: src/wirestate-core/binding/binding.ts:167
Token used to resolve the factory result.
type?
readonly optional type?: "Factory";Defined in: src/wirestate-core/binding/binding.ts:162
Binding strategy. Optional when the descriptor has a factory field.