home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
6.7
  • Packages
    • @ember/application
    • @ember/application/namespace
    • @ember/array
    • @ember/array/proxy
    • @ember/canary-features
    • @ember/component
    • @ember/component/template-only
    • @ember/controller
    • @ember/debug
    • @ember/debug/container-debug-adapter
    • @ember/debug/data-adapter
    • @ember/destroyable
    • @ember/engine
    • @ember/helper
    • @ember/object
    • @ember/object/core
    • @ember/object/evented
    • @ember/object/mixin
    • @ember/object/observable
    • @ember/object/promise-proxy-mixin
    • @ember/object/proxy
    • @ember/owner
    • @ember/renderer
    • @ember/routing
    • @ember/routing/hash-location
    • @ember/routing/history-location
    • @ember/routing/location
    • @ember/routing/none-location
    • @ember/routing/route
    • @ember/routing/route-info
    • @ember/routing/router
    • @ember/routing/router-service
    • @ember/routing/transition
    • @ember/runloop
    • @ember/service
    • @ember/template
    • @ember/test
    • @ember/utils
    • @glimmer/component
    • @glimmer/tracking
    • @glimmer/tracking/primitives/cache
    • rsvp
  • Classes
    • Application
    • ApplicationInstance
    • ApplicationInstance.BootOptions
    • ArrayProxy
    • Component
    • ComputedProperty
    • ContainerDebugAdapter
    • CoreObject
    • DataAdapter
    • Ember.Controller
    • Ember.NativeArray
    • Ember.Templates.helpers
    • Ember.Test
    • Ember.Test.QUnitAdapter
    • EmberArray
    • EmberENV
    • EmberObject
    • EmberRouter
    • Engine
    • EngineInstance
    • EventTarget
    • Evented
    • Factory
    • FactoryManager
    • FullName
    • HashLocation
    • Helper
    • HistoryLocation
    • Location
    • Mixin
    • MutableArray
    • Namespace
    • NoneLocation
    • ObjectProxy
    • Observable
    • Owner
    • Promise
    • PromiseProxyMixin
    • RegisterOptions
    • Renderer
    • Resolver
    • Route
    • RouteInfo
    • RouteInfoWithAttributes
    • RouterService
    • SafeString
    • Service
    • TestAdapter
    • Transition
    • TrustedHTML

Class BasicContainer private


Defined in: packages/@ember/-internals/owner/index.ts:189
Module: @ember/owner

The common interface for the ability to lookup() or get the factoryFor an item, shared by the Owner and ContainerProxy interfaces.


Methods

factoryFor (fullName) : FactoryManager public

Module: @ember/owner

Defined in packages/@ember/-internals/owner/index.ts:247

fullName
String
returns
FactoryManager

Given a FullName, of the form "type:name" return a FactoryManager.

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:

import { getOwner } from '@ember/application';

let owner = 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.

Any instances created via the factory's .create() method must be destroyed manually by the caller of .create(). Typically, this is done during the creating objects own destroy or willDestroy methods.

lookup (fullName, options) : Any public

Module: @ember/owner

Defined in packages/@ember/-internals/owner/index.ts:198

fullName
String
options
RegisterOptions
returns
Any

Given a fullName return a corresponding instance.

The default behavior 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.

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

registry.register('api:twitter', Twitter);

let twitter = container.lookup('api:twitter');

twitter instanceof Twitter; // => true

// by default the container will return singletons
let 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.

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

registry.register('api:twitter', Twitter);

let twitter = container.lookup('api:twitter', { singleton: false });
let twitter2 = container.lookup('api:twitter', { singleton: false });

twitter === twitter2; //=> false
On this page


Methods

  • factoryFor
  • lookup
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.