Skip to content

Commit

Permalink
[DOCS beta] factoryFor docs
Browse files Browse the repository at this point in the history
(cherry picked from commit cf7d680)
  • Loading branch information
mixonic authored and chancancode committed Mar 14, 2017
1 parent 51d039e commit bdb46eb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/ember-runtime/lib/mixins/container_proxy.js
Expand Up @@ -148,6 +148,44 @@ let containerProxyMixin = {
};

if (isFeatureEnabled('ember-factory-for')) {
/**
Given a fullName return a factory manager.
This method returns a manager which can be used for introspection of the
factory's class or for the creation of factory instances with initial
properties. The manager is an object with the following properties:
* `class` - The registered or resolved class.
* `create` - A function that will create an instance of the class with
any dependencies injected.
For example:
```javascript
let owner = Ember.getOwner(otherInstance);
// the owner is commonly the `applicationInstance`, and can be accessed via
// an instance initializer.
let factory = owner.factoryFor('service:bespoke');
factory.class;
// The registered or resolved class. For example when used with an Ember-CLI
// app, this would be the default export from `app/services/bespoke.js`.
let instance = factory.create({
someProperty: 'an initial property value'
});
// Create an instance with any injections and the passed options as
// initial properties.
```
@public
@class ContainerProxyMixin
@method factoryFor
@param {String} fullName
@param {Object} options
@return {FactoryManager}
*/
containerProxyMixin.factoryFor = function ContainerProxyMixin_factoryFor(fullName, options = {}) {
return this.__container__.factoryFor(fullName, options);
};
Expand Down

0 comments on commit bdb46eb

Please sign in to comment.