Home Manual Reference Source Repository
public class | source

Injectable

Extends:

Trait → Injectable

Adds the possibility to inject proxies/methods

Static Method Summary

Static Public Methods
public static

inject(name: string | object, value: function)

Inject a property into future instances

public static

injectProxy(name: string | object, value: function)

Inject a proxy property into future instances

public static

uninject(name: string)

Prevent a property from being injected

Method Summary

Public Methods
public

Inject proxies and methods during the constructor

public

inject(name: string | object, value: function)

Inject a property into the instance

public

injectProxy(name: string, value: function)

Inject a proxy

public

uninject(name: string)

Revert a proxy injection in instance, won't delete non-injected properties

Inherited Summary

From class Trait
public

Optional initialization method

Static Public Methods

public static inject(name: string | object, value: function) source

Inject a property into future instances

Params:

NameTypeAttributeDescription
name string | object

Name of the property

value function

Any function that does not return a proxy

public static injectProxy(name: string | object, value: function) source

Inject a proxy property into future instances

Params:

NameTypeAttributeDescription
name string | object

Name of the property

value function

Either a resource or a function that returns a proxy

Example:


Mapcreator.injectProxy({Domain});

// After creating new api instance

api.domains // returns proxy

public static uninject(name: string) source

Prevent a property from being injected

Params:

NameTypeAttributeDescription
name string

Name of the property

Public Methods

public initializer() source

Inject proxies and methods during the constructor

Override:

Trait#initializer

public inject(name: string | object, value: function) source

Inject a property into the instance

Params:

NameTypeAttributeDescription
name string | object

Name of the property

value function

Any function that does not return a proxy

public injectProxy(name: string, value: function) source

Inject a proxy

Params:

NameTypeAttributeDescription
name string

Name of the property

value function

Either a resource or a function that returns a proxy

public uninject(name: string) source

Revert a proxy injection in instance, won't delete non-injected properties

Params:

NameTypeAttributeDescription
name string

property name

Throw:

*

Error when the property was not injected