ContainerProxyMixin Class packages/ember-runtime/lib/mixins/container_proxy.js:10
PRIVATE
Defined in: packages/ember-runtime/lib/mixins/container_proxy.js:10
Module: ember-runtime
ContainerProxyMixin is used to provide public access to specific container functionality.
Show:
_lookupFactory
(fullName)
Any
private
Given a fullName return the corresponding factory.
Parameters:
- fullName String
Returns:
- Any
lookup
(fullName, options)
Any
public
Given a fullName return a corresponding instance.
The default behaviour is for lookup to return a singleton instance. The singleton is scoped to the container, allowing multiple containers to all have their own locally scoped singletons.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
var registry = new Registry(); var container = registry.container(); registry.register('api:twitter', Twitter); var twitter = container.lookup('api:twitter'); twitter instanceof Twitter; // => true // by default the container will return singletons var twitter2 = container.lookup('api:twitter'); twitter2 instanceof Twitter; // => true twitter === twitter2; //=> true |
If singletons are not wanted an optional flag can be provided at lookup.
1 2 3 4 5 6 7 8 9 |
var registry = new Registry(); var container = registry.container(); registry.register('api:twitter', Twitter); var twitter = container.lookup('api:twitter', { singleton: false }); var twitter2 = container.lookup('api:twitter', { singleton: false }); twitter === twitter2; //=> false |
Parameters:
- fullName String
- options Object
Returns:
- Any
ownerInjection
Object
public
Returns an object that can be used to provide an owner to a manually created instance.
Example:
1 2 3 4 5 6 |
let owner = Ember.getOwner(this); User.create( owner.ownerInjection(), { username: 'rwjblue' } ) |
Returns:
- Object
Show:
__container__
Ember.Container
private
The container stores state.