UNPKG

@loopback/docs

Version:
39 lines (25 loc) 1.32 kB
--- lang: en title: 'API docs: context.instantiateclass' keywords: LoopBack 4.0, LoopBack 4 sidebar: lb4_sidebar permalink: /doc/en/lb4/apidocs.context.instantiateclass.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [instantiateClass](./context.instantiateclass.md) ## instantiateClass() function Create an instance of a class which constructor has arguments decorated with `@inject`<!-- -->. The function returns a class when all dependencies were resolved synchronously, or a Promise otherwise. <b>Signature:</b> ```typescript export declare function instantiateClass<T>(ctor: Constructor<T>, ctx: Context, session?: ResolutionSession, nonInjectedArgs?: any[]): ValueOrPromise<T>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | ctor | <code>Constructor&lt;T&gt;</code> | The class constructor to call. | | ctx | <code>Context</code> | The context containing values for <code>@inject</code> resolution | | session | <code>ResolutionSession</code> | Optional session for binding and dependency resolution | | nonInjectedArgs | <code>any[]</code> | Optional array of args for non-injected parameters | <b>Returns:</b> `ValueOrPromise<T>`