Injector

Classes

Injector
InjectedClass
InjectedEntity
Middleware

Members

(static) InjectType :InjectType

Properties:
Name Type Description
Class number

The Class type. Injects the class.

Function number

The Function type. Injects the function.

FunctionResult number

The FunctionResult type. Injects the function's result.

Variable number

The Variable type. Injects the variable.

Middleware number

The Middleware type. Injects the middleware as a Class

Source:

Methods

(static) Inject(constructor) → {any}

This decorator is used to inject a class.

Parameters:
Name Type Description
constructor function
Source:
Example

Example usage of @Inject.

// InjectedClass is optional, only if you want to use the onReady function.
@Inject
export default class ClassName implements InjectedClass {
   // Mandatory if you have InjectedClass.
   public async onReady(): Promise<void> {

   }
}

(static) Retrieve(name) → {any}

This decorator is used to Retrieve/get an injected object/variable. The Retrieve decorator only works on the classes that have @Inject or @Action For functions/classes that can't use @Retrieve, use Injector.get()

Parameters:
Name Type Description
name string

The name of the object/variable.

Source:
Example

Example usage of @Retrieve.

export default class ClassName {
   @Retrieve('name')
   private variable?: Type;
}