UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

48 lines (31 loc) 1.23 kB
--- lang: en title: 'API docs: context.binding.todynamicvalue' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/context permalink: /doc/en/lb4/apidocs.context.binding.todynamicvalue.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [Binding](./context.binding.md) &gt; [toDynamicValue](./context.binding.todynamicvalue.md) ## Binding.toDynamicValue() method Bind the key to a computed (dynamic) value. <b>Signature:</b> ```typescript toDynamicValue(factory: ValueFactory<T> | DynamicValueProviderClass<T>): this; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | factory | [ValueFactory](./context.valuefactory.md)<!-- -->&lt;T&gt; \| [DynamicValueProviderClass](./context.dynamicvalueproviderclass.md)<!-- -->&lt;T&gt; | | <b>Returns:</b> this ## Example ```ts // synchronous ctx.bind('now').toDynamicValue(() => Date.now()); // asynchronous ctx.bind('something').toDynamicValue( async () => Promise.delay(10).then(doSomething) ); ```