Home Reference Source
import {Injection} from 'arva-js/utils/Injection.js'
public class | source

Injection

Static Method Summary

Static Public Methods
public static

addProviders(classConstructors: *): void

Registers classes as the default provider for their Provide annotation (set by @provide decorator).

public static

get(classConstructor: Function, constructionParams: *): Object

Requests an instance of the given class from the DI engine.

public static

getAll(classContructorArray: *): Array

Requests instances of multiple classes at once.

public static

provide(classConstructor: Function)

Provide an instance a certain type.

public static

provideAndGet(classConstructor: Class, functionOrConstructedObject: Function | Object): *

Provide an instance a certain type.

Static Public Methods

public static addProviders(classConstructors: *): void source

Registers classes as the default provider for their Provide annotation (set by @provide decorator).

Example usage: addProviders(ArvaRouter, FamousContext);

Params:

NameTypeAttributeDescription
classConstructors *

Return:

void

public static get(classConstructor: Function, constructionParams: *): Object source

Requests an instance of the given class from the DI engine. If an instance of that class with the same construction parameters already exists, a reference to it is returned. Otherwise a new instance is created.

Example usage: get(HomeController, param1, param2);

Params:

NameTypeAttributeDescription
classConstructor Function

The class of which an instance is wanted

constructionParams *

A list of parameters to be passed to the class constructor

Return:

Object

Instance of the given class

public static getAll(classContructorArray: *): Array source

Requests instances of multiple classes at once.

Example usage: let instances = getAll(ArvaRouter, [HomeController, [param1, param2]], App);

Params:

NameTypeAttributeDescription
classContructorArray *

Array of classes to instantiate. May also be an array where each item is an array containing the class as its first element, and an array of parameters as its second element.

Return:

Array

An array of instances of the requested classes

public static provide(classConstructor: Function) source

Provide an instance a certain type.

Params:

NameTypeAttributeDescription
classConstructor Function

The class of which an instance is wanted

functionOrConstructedObject. Function | Object

A function returning an instance of the object, or the object itself.

public static provideAndGet(classConstructor: Class, functionOrConstructedObject: Function | Object): * source

Provide an instance a certain type.

Params:

NameTypeAttributeDescription
classConstructor Class

The class of which an instance is wanted

functionOrConstructedObject Function | Object

Return:

*