Skip to content

Interface: InstanceBindingDescriptor<T>

Defined in: src/wirestate-core/binding/binding.ts:111

Describes a token-bound service instance constructed from an injectable class.

Remarks

Use an instance binding when the token callers resolve should be explicit: an interface-shaped InjectionToken, an abstract class, a base class, or a class token mapped to a subclass implementation. A bare class binding is shorthand for an instance binding whose token and value are the same class.

Singleton instance bindings are cached, owned by the container, and wired into service lifecycle, provider lifecycle, and messaging. Transient instance bindings create a fresh instance for every resolution and are not cached or owned. Container rejects transient instance classes that declare lifecycle or messaging handlers because those handlers would have no owned lifetime.

Type Parameters

Type ParameterDefault typeDescription
TunknownInstance type resolved for the token.

Properties

scope?

ts
readonly optional scope?: "Singleton" | "Transient";

Defined in: src/wirestate-core/binding/binding.ts:141

Lifetime scope for the instance.

Remarks

Defaults to Singleton: the value is constructed once, cached, and owned by the container with full instance lifecycle. A Transient value is constructed fresh on every resolution and is never cached or owned, so its class must declare no wirestate lifecycle or messaging handlers. The container rejects a transient instance class that declares handlers at bind time.


token

ts
readonly token: ServiceToken<T>;

Defined in: src/wirestate-core/binding/binding.ts:120

Token used to resolve the constructed instance.


type

ts
readonly type: "Instance";

Defined in: src/wirestate-core/binding/binding.ts:115

Binding strategy for injectable class construction.


value

ts
readonly value: Newable<NoInfer<T>>;

Defined in: src/wirestate-core/binding/binding.ts:129

Injectable service constructor used to create the instance.

Remarks

The constructor must be assignable to the token's resolved type and must be decorated with @Injectable().