Function: getBindingType()
ts
function getBindingType(binding: Binding): "Value" | "Instance" | "Factory";Defined in: src/wirestate-core/binding/binding-lifecycle.ts:30
Resolves the binding kind of a binding.
Parameters
| Parameter | Type | Description |
|---|---|---|
binding | Binding | Service class or descriptor to inspect. |
Returns
"Value" | "Instance" | "Factory"
The binding kind, inferred from the binding shape when not declared.
Remarks
A bare service class binds as an instance binding. For a descriptor, an explicit type wins, a factory field means a factory binding, and anything else is a value binding. Use it instead of reading type directly, which is optional for value and factory descriptors and absent on a bare class.
Example
typescript
import { getBindingType, Injectable } from "@wirestate/core";
@Injectable()
class UserService {}
getBindingType(UserService); // "Instance"
getBindingType({ token: "API_URL", value: "https://api.example.com" }); // "Value"
getBindingType({ token: "API_CLIENT", factory: () => createClient() }); // "Factory"