@loopback/docs
Version:
Documentation for LoopBack 4
2,119 lines (1,520 loc) • 184 kB
HTML
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/code-themes/sl-theme.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">docs.strongloop.com</a>
</div>
<div id="modules"></div>
</div>
<div class="row">
<div class="col-lg-3 column scroll-spy-target">
<ul class="nav nav-pills nav-stacked">
<div id="versions"></div>
<li class="depth-3">
<a href="#BindingScope">Enum: BindingScope</a>
</li>
<li class="depth-4">
<a href="#BindingScope.CONTEXT">CONTEXT</a>
</li>
<li class="depth-4">
<a href="#BindingScope.SINGLETON">SINGLETON</a>
</li>
<li class="depth-4">
<a href="#BindingScope.TRANSIENT">TRANSIENT</a>
</li>
<li class="depth-3">
<a href="#BindingType">Enum: BindingType</a>
</li>
<li class="depth-4">
<a href="#BindingType.CLASS">CLASS</a>
</li>
<li class="depth-4">
<a href="#BindingType.CONSTANT">CONSTANT</a>
</li>
<li class="depth-4">
<a href="#BindingType.DYNAMIC_VALUE">DYNAMIC_VALUE</a>
</li>
<li class="depth-4">
<a href="#BindingType.PROVIDER">PROVIDER</a>
</li>
<li class="depth-3">
<a href="#Binding">Class: Binding</a>
</li>
<li class="depth-4">
<a href="#Binding.constructor">constructor()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.isLocked">isLocked</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.key">key</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.scope">scope</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.tagMap">tagMap</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.type">type</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.valueConstructor">valueConstructor</a>
</li>
<li class="depth-4">
<a href="#Binding.tagNames">>tagNames</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.getValue">getValue()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.inScope">inScope()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.lock">lock()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.tag">tag()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.to">to()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.toClass">toClass()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.toDynamicValue">toDynamicValue()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.toJSON">toJSON()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.toProvider">toProvider()</a>
</li>
<li class="depth-4">
<a href="#Binding.prototype.unlock">unlock()</a>
</li>
<li class="depth-3">
<a href="#TagMap">Type: TagMap</a>
</li>
<li class="depth-3">
<a href="#BindingKey">Class: BindingKey</a>
</li>
<li class="depth-4">
<a href="#BindingKey.PROPERTY_SEPARATOR">static PROPERTY_SEPARATOR</a>
</li>
<li class="depth-4">
<a href="#BindingKey.prototype.deepProperty">deepProperty()</a>
</li>
<li class="depth-4">
<a href="#BindingKey.prototype.toString">toString()</a>
</li>
<li class="depth-4">
<a href="#BindingKey.create">static create()</a>
</li>
<li class="depth-4">
<a href="#BindingKey.parseKeyWithPath">static parseKeyWithPath()</a>
</li>
<li class="depth-4">
<a href="#BindingKey.validate">static validate()</a>
</li>
<li class="depth-3">
<a href="#BindingAddress">Type: BindingAddress</a>
</li>
<li class="depth-3">
<a href="#Context">Class: Context</a>
</li>
<li class="depth-4">
<a href="#Context.constructor">constructor()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.name">name</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.bind">bind()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.contains">contains()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.find">find()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.findByTag">findByTag()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.get">get()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.getBinding">getBinding()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.getOwnerContext">getOwnerContext()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.getSync">getSync()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.getValueOrPromise">getValueOrPromise()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.isBound">isBound()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.toJSON">toJSON()</a>
</li>
<li class="depth-4">
<a href="#Context.prototype.unbind">unbind()</a>
</li>
<li class="depth-3">
<a href="#inject">Namespace: inject</a>
</li>
<li class="depth-4">
<a href="#inject.context">context()</a>
</li>
<li class="depth-4">
<a href="#inject.getter">getter()</a>
</li>
<li class="depth-4">
<a href="#inject.setter">setter()</a>
</li>
<li class="depth-4">
<a href="#inject.tag">tag()</a>
</li>
<li class="depth-3">
<a href="#Injection">Interface: Injection</a>
</li>
<li class="depth-4">
<a href="#Injection.prototype.bindingKey">bindingKey</a>
</li>
<li class="depth-4">
<a href="#Injection.prototype.member">member</a>
</li>
<li class="depth-4">
<a href="#Injection.prototype.metadata">metadata</a>
</li>
<li class="depth-4">
<a href="#Injection.prototype.methodDescriptorOrParameterIndex">methodDescriptorOrParameterIndex</a>
</li>
<li class="depth-4">
<a href="#Injection.prototype.resolve">resolve</a>
</li>
<li class="depth-4">
<a href="#Injection.prototype.target">target</a>
</li>
<li class="depth-3">
<a href="#InjectionMetadata">Interface: InjectionMetadata</a>
</li>
<li class="depth-4">
<a href="#InjectionMetadata.prototype.decorator">decorator</a>
</li>
<li class="depth-4">
<a href="#InjectionMetadata.prototype.optional">optional</a>
</li>
<li class="depth-3">
<a href="#ResolverFunction">Interface: ResolverFunction</a>
</li>
<li class="depth-3">
<a href="#Getter">Type: Getter</a>
</li>
<li class="depth-3">
<a href="#Setter">Type: Setter</a>
</li>
<li class="depth-3">
<a href="#describeInjectedArguments">describeInjectedArguments()</a>
</li>
<li class="depth-3">
<a href="#describeInjectedProperties">describeInjectedProperties()</a>
</li>
<li class="depth-3">
<a href="#Provider">Interface: Provider</a>
</li>
<li class="depth-4">
<a href="#Provider.prototype.value">value()</a>
</li>
<li class="depth-3">
<a href="#ResolutionSession">Class: ResolutionSession</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.stack">stack</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.bindingStack">>bindingStack</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.currentBinding">>currentBinding</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.currentInjection">>currentInjection</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.injectionStack">>injectionStack</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.getBindingPath">getBindingPath()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.getInjectionPath">getInjectionPath()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.getResolutionPath">getResolutionPath()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.popBinding">popBinding()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.popInjection">popInjection()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.pushBinding">pushBinding()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.prototype.pushInjection">pushInjection()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.describeInjection">static describeInjection()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.fork">static fork()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.runWithBinding">static runWithBinding()</a>
</li>
<li class="depth-4">
<a href="#ResolutionSession.runWithInjection">static runWithInjection()</a>
</li>
<li class="depth-3">
<a href="#BindingElement">Interface: BindingElement</a>
</li>
<li class="depth-4">
<a href="#BindingElement.prototype.type">type</a>
</li>
<li class="depth-4">
<a href="#BindingElement.prototype.value">value</a>
</li>
<li class="depth-3">
<a href="#InjectionElement">Interface: InjectionElement</a>
</li>
<li class="depth-4">
<a href="#InjectionElement.prototype.type">type</a>
</li>
<li class="depth-4">
<a href="#InjectionElement.prototype.value">value</a>
</li>
<li class="depth-3">
<a href="#ResolutionOptions">Interface: ResolutionOptions</a>
</li>
<li class="depth-4">
<a href="#ResolutionOptions.prototype.optional">optional</a>
</li>
<li class="depth-4">
<a href="#ResolutionOptions.prototype.session">session</a>
</li>
<li class="depth-3">
<a href="#ResolutionAction">Type: ResolutionAction</a>
</li>
<li class="depth-3">
<a href="#ResolutionElement">Type: ResolutionElement</a>
</li>
<li class="depth-3">
<a href="#instantiateClass">instantiateClass()</a>
</li>
<li class="depth-3">
<a href="#invokeMethod">invokeMethod()</a>
</li>
<li class="depth-3">
<a href="#resolveInjectedArguments">resolveInjectedArguments()</a>
</li>
<li class="depth-3">
<a href="#resolveInjectedProperties">resolveInjectedProperties()</a>
</li>
<li class="depth-3">
<a href="#BoundValue">Type: BoundValue</a>
</li>
<li class="depth-3">
<a href="#Constructor">Type: Constructor</a>
</li>
<li class="depth-3">
<a href="#MapObject">Type: MapObject</a>
</li>
<li class="depth-3">
<a href="#ValueOrPromise">Type: ValueOrPromise</a>
</li>
<li class="depth-3">
<a href="#getDeepProperty">getDeepProperty()</a>
</li>
<li class="depth-3">
<a href="#isPromiseLike">isPromiseLike()</a>
</li>
<li class="depth-3">
<a href="#resolveList">resolveList()</a>
</li>
<li class="depth-3">
<a href="#resolveMap">resolveMap()</a>
</li>
<li class="depth-3">
<a href="#resolveUntil">resolveUntil()</a>
</li>
<li class="depth-3">
<a href="#transformValueOrPromise">transformValueOrPromise()</a>
</li>
<li class="depth-3">
<a href="#tryWithFinally">tryWithFinally()</a>
</li>
</ul>
</div>
<div class="col-lg-9 col-lg-offset-3 column" data-spy="scroll" data-target=".scroll-spy-target" data-offset="0">
<div class="readability">
<section class="code-doc ">
<a name="BindingScope"></a>
<h3 class="code-ref">Enumeration: BindingScope</h3>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Scope for binding values</p>
</p>
<p></p>
</div>
</section>
<section class="code-doc">
<div class="code-arguments-hdr">Members</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name="BindingScope.CONTEXT"></a>
<strong class="code-arg-name">CONTEXT</strong>
</td>
<td class="code-arg-default-value">
"Context"
</td>
<td class="code-arg-flags">
exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>The binding provides a value as a singleton within each local context. The
value is calculated only once per context and cached for subsequenicial
uses. Child contexts have their own value and do not share with their
ancestors.</p>
</p>
<p><p>For example, with the following context hierarchy:</p>
<ul>
<li>app (with a binding 'b1' that produces sequential values 0, 1, ...)<ul>
<li>req1</li>
<li>req2</li>
</ul>
</li>
</ul>
<p>// 0 is the singleton for app afterward
app.get('b1') ==> 0</p>
<p>// 'b1' is found in app but not in req1, a new value 1 is calculated.
// 1 is the singleton for req1 afterward
req1.get('b1') ==> 1</p>
<p>// 'b1' is found in app but not in req2, a new value 2 is calculated.
// 2 is the singleton for req2 afterward
req2.get('b1') ==> 2</p>
</p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="BindingScope.SINGLETON"></a>
<strong class="code-arg-name">SINGLETON</strong>
</td>
<td class="code-arg-default-value">
"Singleton"
</td>
<td class="code-arg-flags">
exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>The binding provides a value as a singleton within the context hierarchy
(the owning context and its descendants). The value is calculated only
once for the owning context and cached for subsequenicial uses. Child
contexts share the same value as their ancestors.</p>
</p>
<p><p>For example, with the following context hierarchy:</p>
<ul>
<li>app (with a binding 'b1' that produces sequential values 0, 1, ...)<ul>
<li>req1</li>
<li>req2</li>
</ul>
</li>
</ul>
<p>// 0 is the singleton for app afterward
app.get('b1') ==> 0</p>
<p>// 'b1' is found in app, reuse it
req1.get('b1') ==> 0</p>
<p>// 'b1' is found in app, reuse it
req2.get('b1') ==> 0</p>
</p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="BindingScope.TRANSIENT"></a>
<strong class="code-arg-name">TRANSIENT</strong>
</td>
<td class="code-arg-default-value">
"Transient"
</td>
<td class="code-arg-flags">
exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>The binding provides a value that is calculated each time. This will be
the default scope if not set.</p>
</p>
<p><p>For example, with the following context hierarchy:</p>
<ul>
<li>app (with a binding 'b1' that produces sequential values 0, 1, ...)<ul>
<li>req1</li>
<li>req2</li>
</ul>
</li>
</ul>
<p>// get('b1') produces a new value each time for app and its descendants
app.get('b1') ==> 0
req1.get('b1') ==> 1
req2.get('b1') ==> 2
req2.get('b1') ==> 3
app.get('b1') ==> 4</p>
</p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="BindingType"></a>
<h3 class="code-ref">Enumeration: BindingType</h3>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Type of the binding source</p>
</p>
<p></p>
</div>
</section>
<section class="code-doc">
<div class="code-arguments-hdr">Members</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name="BindingType.CLASS"></a>
<strong class="code-arg-name">CLASS</strong>
</td>
<td class="code-arg-default-value">
"Class"
</td>
<td class="code-arg-flags">
exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>A class to be instantiated as the value</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="BindingType.CONSTANT"></a>
<strong class="code-arg-name">CONSTANT</strong>
</td>
<td class="code-arg-default-value">
"Constant"
</td>
<td class="code-arg-flags">
exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>A fixed value</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="BindingType.DYNAMIC_VALUE"></a>
<strong class="code-arg-name">DYNAMIC_VALUE</strong>
</td>
<td class="code-arg-default-value">
"DynamicValue"
</td>
<td class="code-arg-flags">
exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>A function to get the value</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="BindingType.PROVIDER"></a>
<strong class="code-arg-name">PROVIDER</strong>
</td>
<td class="code-arg-default-value">
"Provider"
</td>
<td class="code-arg-flags">
exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>A provider class with <code>value()</code> function to get the value</p>
</p>
<p></p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding"></a>
<h3 class="code-ref">Class: binding = new Binding()</h3>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Binding represents an entry in the <code>Context</code>. Each binding has a key and a
corresponding value getter.</p>
</p>
<p></p>
</div>
</section>
<section class="code-doc">
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Properties</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name="Binding.prototype.isLocked"></a>
<strong class="code-arg-name">
isLocked
</strong>
</td>
<td class="code-arg-types">
<code>boolean</code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
constructorProperty exported public
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Binding represents an entry in the <code>Context</code>. Each binding has a key and a
corresponding value getter.</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="Binding.prototype.key"></a>
<strong class="code-arg-name">
key
</strong>
</td>
<td class="code-arg-types">
<code>string</code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
exported public
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Key of the binding</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="Binding.prototype.scope"></a>
<strong class="code-arg-name">
scope
</strong>
</td>
<td class="code-arg-types">
<code><a href="#BindingScope">BindingScope</a></code>
</td>
<td class="code-arg-default-value">
BindingScope.TRANSIENT
</td>
<td class="code-arg-flags">
exported public
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Scope of the binding to control how the value is cached/shared</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="Binding.prototype.tagMap"></a>
<strong class="code-arg-name">
tagMap
</strong>
</td>
<td class="code-arg-types">
<code><a href="#TagMap">TagMap</a></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
exported public
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Map for tag name/value pairs</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="Binding.prototype.type"></a>
<strong class="code-arg-name">
type
</strong>
</td>
<td class="code-arg-types">
<code><a href="#BindingType">BindingType</a></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
exported public
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Type of the binding value getter</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name="Binding.prototype.valueConstructor"></a>
<strong class="code-arg-name">
valueConstructor
</strong>
</td>
<td class="code-arg-types">
<code><a href="#Constructor">Constructor</a><T></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
exported public
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>For bindings bound via toClass, this property contains the constructor
function</p>
</p>
<p></p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.constructor"></a>
<h4 class="code-ref">constructor(key: string, isLocked: boolean) : <a href="#Binding">Binding</a></h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
key
</strong>
</td>
<td class="code-arg-types">
<code>string</code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Binding represents an entry in the <code>Context</code>. Each binding has a key and a
corresponding value getter.</p>
</p>
<p></p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
isLocked
</strong>
</td>
<td class="code-arg-types">
<code>boolean</code>
</td>
<td class="code-arg-default-value">
false
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Binding represents an entry in the <code>Context</code>. Each binding has a key and a
corresponding value getter.</p>
</p>
<p></p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.tagNames"></a>
<h4 class="code-ref">tagNames() : string[]</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p>Get an array of tag names</p>
<p></p>
</div>
</section>
<section class="code-doc ">
<a name="Binding.prototype.getValue"></a>
<h4 class="code-ref">getValue(ctx: <a href="#Context">Context</a>, session: <a href="#ResolutionSession">ResolutionSession</a>) : <a href="#ValueOrPromise">ValueOrPromise</a><T></h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>This is an internal function optimized for performance.
Users should use <code>@inject(key)</code> or <code>ctx.get(key)</code> instead.</p>
</p>
<p><p>Get the value bound to this key. Depending on <code>isSync</code>, this
function returns either:</p>
<ul>
<li>the bound value</li>
<li>a promise of the bound value</li>
</ul>
<p>Consumers wishing to consume sync values directly should use <code>isPromise</code>
to check the type of the returned value to decide how to handle it.</p>
<pre><code>const <span class="hljs-literal">result</span> = binding.getValue(ctx);
<span class="hljs-keyword">if</span> (isPromiseLike(<span class="hljs-literal">result</span>)) {
<span class="hljs-literal">result</span>.<span class="hljs-keyword">then</span>(doSomething)
} <span class="hljs-keyword">else</span> {
doSomething(<span class="hljs-literal">result</span>);
}</code></pre></p>
</div>
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
ctx
</strong>
</td>
<td class="code-arg-types">
<code><a href="#Context">Context</a></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p></p>
<p><p>Context for the resolution</p>
</p>
</div>
</td>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
session
</strong>
</td>
<td class="code-arg-types">
<code><a href="#ResolutionSession">ResolutionSession</a></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
optional
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p></p>
<p><p>Optional session for binding and dependency resolution</p>
</p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.prototype.inScope"></a>
<h4 class="code-ref">inScope(scope: <a href="#BindingScope">BindingScope</a>) : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
scope
</strong>
</td>
<td class="code-arg-types">
<code><a href="#BindingScope">BindingScope</a></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Binding represents an entry in the <code>Context</code>. Each binding has a key and a
corresponding value getter.</p>
</p>
<p></p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.prototype.lock"></a>
<h4 class="code-ref">lock() : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
</section>
<section class="code-doc ">
<a name="Binding.prototype.tag"></a>
<h4 class="code-ref">tag(tags: (string | anonymous)[]) : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>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.</p>
</p>
<p></p>
</div>
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
tags
</strong>
</td>
<td class="code-arg-types">
<code>(string | anonymous)[]</code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
rest
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p></p>
<p><p>A list of names or name/value objects. Each
parameter can be in one of the following forms:</p>
<ul>
<li>string: A tag name without value</li>
<li>string[]: An array of tag names</li>
<li>TagMap: A map of tag name/value pairs</li>
</ul>
</p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.prototype.to"></a>
<h4 class="code-ref">to(value: T) : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>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.</p>
</p>
<p></p>
</div>
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
value
</strong>
</td>
<td class="code-arg-types">
<code>T</code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p></p>
<p><p>The bound value.</p>
</p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.prototype.toClass"></a>
<h4 class="code-ref">toClass(ctor: <a href="#Constructor">Constructor</a><T>) : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Bind the key to an instance of the given class.</p>
</p>
<p></p>
</div>
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
ctor
</strong>
</td>
<td class="code-arg-types">
<code><a href="#Constructor">Constructor</a><T></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p></p>
<p><p>The class constructor to call. Any constructor
arguments must be annotated with <code>@inject</code> so that
we can resolve them from the context.</p>
</p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.prototype.toDynamicValue"></a>
<h4 class="code-ref">toDynamicValue(factoryFn: () => <a href="#ValueOrPromise">ValueOrPromise</a><T>) : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Bind the key to a computed (dynamic) value.</p>
</p>
<p></p>
</div>
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
factoryFn
</strong>
</td>
<td class="code-arg-types">
<code>anonymous</code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p></p>
<p><p>The factory function creating the value.
Both sync and async functions are supported.</p>
</p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.prototype.toJSON"></a>
<h4 class="code-ref">toJSON() : <a href="#Object">Object</a></h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
</section>
<section class="code-doc ">
<a name="Binding.prototype.toProvider"></a>
<h4 class="code-ref">toProvider(providerClass: <a href="#Constructor">Constructor</a><<a href="#Provider">Provider</a><T>>) : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Bind the key to a value computed by a Provider.</p>
</p>
<p><ul>
<li>@example</li>
</ul>
<pre><code class="language-ts"><span class="hljs-keyword">export</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DateProvider</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Provider</span><<span class="hljs-title">Date</span>> </span>{
constructor(<span class="hljs-meta">@inject</span>(<span class="hljs-string">'stringDate'</span>) private param: <span class="hljs-built_in">String</span>){}
value(): Date {
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Date(param);
}
}</code></pre>
</p>
</div>
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
providerClass
</strong>
</td>
<td class="code-arg-types">
<code><a href="#Constructor">Constructor</a><<a href="#Provider">Provider</a><T>></code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Binding represents an entry in the <code>Context</code>. Each binding has a key and a
corresponding value getter.</p>
</p>
<p></p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="Binding.prototype.unlock"></a>
<h4 class="code-ref">unlock() : this</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
</section>
<section class="code-doc ">
<a name="TagMap"></a>
<h3 class="code-ref">Type alias: TagMap = MapObject</h3>
</section>
<section class="code-doc ">
<a name="BindingKey"></a>
<h3 class="code-ref">Class: bindingkey = new BindingKey()</h3>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
</section>
<section class="code-doc">
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Properties</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name="BindingKey.PROPERTY_SEPARATOR"></a>
<strong class="code-arg-name">
PROPERTY_SEPARATOR
</strong>
</td>
<td class="code-arg-types">
<code></code>
</td>
<td class="code-arg-default-value">
"#"
</td>
<td class="code-arg-flags">
static exported
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="BindingKey.prototype.deepProperty"></a>
<h4 class="code-ref">deepProperty(propertyPath: string) : <a href="#BindingKey">BindingKey</a><PropertyValueType></h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Get a binding address for retrieving a deep property of the object
bound to the current binding key.</p>
</p>
<p></p>
</div>
<!-- A table of members such as parameters/properties/variables -->
<div class="code-arguments-hdr">Parameters</div>
<table class="params code-arguments">
<tr>
<th class="hdr-name">Name</th>
<th class="hdr-type">Type</th>
<th class="hdr-default-value">Default Value</th>
<th class="hdr-flags">Flags</th>
<th class="hdr-desc">Description</th>
</tr>
<tr class="code-arg">
<td>
<a name=""></a>
<strong class="code-arg-name">
propertyPath
</strong>
</td>
<td class="code-arg-types">
<code>string</code>
</td>
<td class="code-arg-default-value">
</td>
<td class="code-arg-flags">
</td>
<td class="code-arg-desc">
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p></p>
<p><p>A dot-separated path to a (deep) property, e.g. "server.port".</p>
</p>
</div>
</td>
</tr>
</table>
</section>
<section class="code-doc ">
<a name="BindingKey.prototype.toString"></a>
<h4 class="code-ref">toString() : string</h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
</section>
<section class="code-doc ">
<a name="BindingKey.create"></a>
<h4 class="code-ref">create(key: string, propertyPath: undefined | string) : <a href="#BindingKey">BindingKey</a><ValueType></h4>
<!--
Used for displaying comments in Class, Interface, Properties Constructor,
Function and Parameters of constructor or function.
(Excludes Type alias).
-->
<div class="code-desc">
<p><p>Create a new key for a binding bound to a value of type <code>ValueType</code>.</p>
</p>
<p><p><strong>Example</strong></p>
<pre><code class="language-ts">BindingKey.create<<span class="hljs-built_in">string</span>>('<span class="hljs-built_in">applicat