Page Contents
Home > @loopback/context > instantiateClass
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.
Signature:
export declare function instantiateClass<T extends object>(ctor: Constructor<T>, ctx: Context, session?: ResolutionSession, nonInjectedArgs?: any[]): ValueOrPromise<T>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| ctor | [Constructor](/doc/en/lb4/apidocs.context.constructor.html)<T> | The class constructor to call. |
| ctx | [Context](/doc/en/lb4/apidocs.context.context.html) | The context containing values for `@inject` resolution |
| session | [ResolutionSession](/doc/en/lb4/apidocs.context.resolutionsession.html) | _(Optional)_ Optional session for binding and dependency resolution |
| nonInjectedArgs | any\[\] | _(Optional)_ Optional array of args for non-injected parameters |
Returns: