new ResolutionContext(options)
Private constructor. Instances are normally created internally and passed to resolvers.
Parameters:
Name | Type | Description |
---|---|---|
options |
Methods
-
component()
-
Get the component being resolved. This is the same instance that was passed into the Container#register method.
Returns:
- Type
- *
-
key()
-
Get the key of the component being resolved.
Returns:
The component key.- Type
- String
-
keyStack()
-
Obtain a list of keys for resolutions that triggered this resolution. This list will always have at least one element, and the last element always being the same as this context's #key result.
Returns:
A stack of key names.- Type
- Array.<String>
-
previous()
-
Obtain the previous context in the resolution chain.
Returns:
- Type
- ResolutionContext | null
-
resolve(deps, options)
-
Resolve the given Dependency instance or instances using the same container in which the component for this resolution lives.
Parameters:
Name Type Argument Description deps
String | Array.<String> | Dependency | Array.<Dependency> A Dependency instance or Array of instances. options
Object <optional>
Configuration options. Properties
Name Type Argument Default Description optional
boolean <optional>
false When true
, the specified dependencies are treated as optional.Returns:
A promise that resolves a structure containing resolved dependencies:{map: {}, list: Array}
.- Type
- Promise
-
store(key, value)
-
Provides access to arbitrary data that is stored at the scope of the component registration. This allows a resolver to preserve state across several resolutions of a single component.
Parameters:
Name Type Description key
String The optional data key. value
* The optional data value. Example
// Set a value ctx.store('dogCount', 3); // Get a value ctx.store('dogCount'); // -> 3 // Get all values ctx.store(); // -> { 'dogCount': 3 }
-
toString()
-
Obtain a string representation of this instance.
Returns:
- Type
- string