Registry#typeInjection()

typeInjection (type, property, fullName) private

Defined in packages/container/lib/registry.js:435

Used only via injection.

Provides a specialized form of injection, specifically enabling all objects of one type to be injected with a reference to another object.

For example, provided each object of type controller needed a router. one would do the following:

let registry = new Registry();
let container = registry.container();

registry.register('router:main', Router);
registry.register('controller:user', UserController);
registry.register('controller:post', PostController);

registry.typeInjection('controller', 'router', 'router:main');

let user = container.lookup('controller:user');
let post = container.lookup('controller:post');

user.router instanceof Router; //=> true
post.router instanceof Router; //=> true

// both controllers share the same router
user.router === post.router; //=> true

Parameters:

type String
property String
fullName String
doc_EmberJs
2016-11-30 16:52:58
Comments
Leave a Comment

Please login to continue.