Home > @loopback/context > Binding
Binding class
Binding represents an entry in the Context. Each binding has a key and a corresponding value getter.
Signature:
export declare class Binding<T = BoundValue> extends EventEmitter
Extends: EventEmitter
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
|
Constructs a new instance of the |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
|
boolean | |||
|
|
string |
Key of the binding | |
|
|
Constructor<Provider<T>> | undefined |
For bindings bound via | |
|
|
Scope of the binding to control how the value is cached/shared | ||
|
|
BindingSource<T> | undefined | ||
|
|
Map for tag name/value pairs | ||
|
|
string[] |
Get an array of tag names | |
|
|
BindingType | undefined |
Type of the binding value getter | |
|
|
Constructor<T> | undefined |
For bindings bound via |
Methods
| Method | Modifiers | Description |
|---|---|---|
|
Apply one or more template functions to set up the binding with scope, tags, and other attributes as a group. | ||
|
Apply default scope to the binding. It only changes the scope if it’s not set yet | ||
|
|
A static method to create a binding so that we can do | |
|
|
Create a configuration binding for the given key | |
|
This is an internal function optimized for performance. Users should use Get the value bound to this key. Depending on Consumers wishing to consume sync values directly should use | ||
|
Returns a value or promise for this binding in the given context. The resolved value can be | ||
|
Set the binding scope | ||
|
Inspect the binding to return a json representation of the binding information | ||
|
Lock the binding so that it cannot be rebound | ||
|
The “changed” event is emitted by methods such as | ||
|
The “changed” event is emitted by methods such as | ||
|
Invalidate the binding cache so that its value will be reloaded next time. This is useful to force reloading a cached value when its configuration or dependencies are changed. **WARNING**: The state held in the cached value will be gone. | ||
|
Tag the binding with names or name/value objects. A tag has a name and an optional value. If not supplied, the tag name is used as the value. | ||
|
Bind the key to a constant value. The value must be already available at binding time, it is not allowed to pass a Promise instance. | ||
|
Bind the key to an alias of another binding | ||
|
Bind the key to an instance of the given class. | ||
|
Bind the key to a computed (dynamic) value. | ||
|
Bind to a class optionally decorated with This is similar to createBindingFromClass() but applies to an existing binding. | ||
|
Convert to a plain JSON object | ||
|
Bind the key to a value computed by a Provider. * | ||
|
Unlock the binding |