Class Application

An instance of Ember.Application is the starting point for every Ember application. It helps to instantiate, initialize and coordinate the many objects that make up your app.

Hierarchy

Index

Properties

Methods

Properties

public Router: Router

Application's router.

public addObserver: ModifyObserver

public concatenatedProperties: Array<any>

Defines the properties that will be concatenated from the superclass (instead of overridden).

public customEvents: {}

The DOM events for which the event dispatcher should listen.

public eventDispatcher: EventDispatcher

The Ember.EventDispatcher responsible for delegating events to this application's views.

public isDestroyed: boolean

Destroyed object property flag. If this property is true the observers and bindings were already removed by the effect of calling the destroy() method.

public isDestroying: boolean

Destruction scheduled flag. The destroy() method has been called. The object stays intact until the end of the run loop at which point the isDestroyed flag is set.

public ready: Function

Called when the Application has become ready. The call will be delayed until the DOM has become ready.

public resolver: DefaultResolver

Set this to provide an alternate class to Ember.DefaultResolver

public rootElement: HTMLElement

The root DOM element of the Application. This can be specified as an element or a jQuery-compatible selector string.

This is the element that will be passed to the Application's, eventDispatcher, which sets up the listeners for event delegation. Every view in your application should be a child of the element you specify here.

Methods

public advanceReadiness()

Call advanceReadiness after any asynchronous setup logic has completed. Each call to deferReadiness must be matched by a call to advanceReadiness or the application will never become ready and routing will not begin.

public beginPropertyChanges(): Observable

Returns

Observable

public cacheFor(keyName: string): any

Parameters

  • keyName: string

Returns

any

public decrementProperty(keyName: string, decrement?: number): number

Parameters

  • keyName: string
  • decrement?: number optional

Returns

number

public deferReadiness()

Use this to defer readiness until some condition is true.

This allows you to perform asynchronous setup logic and defer booting your application until the setup has finished.

However, if the setup requires a loading UI, it might be better to use the router for this purpose.

public destroy(): CoreObject

Destroys an object by setting the isDestroyed flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately.

Returns

CoreObject

public endPropertyChanges(): Observable

Returns

Observable

public get(keyName: string): any

Parameters

  • keyName: string

Returns

any

public getProperties(string?: Array<any>): {}

Parameters

  • string?: Array<any> optional

Returns

{}

public getProperties(keys: Array<string>): {}

Parameters

  • keys: Array<string>

Returns

{}

public getWithDefault(keyName: string, defaultValue: any): any

Parameters

  • keyName: string
  • defaultValue: any

Returns

any

public hasObserverFor(key: string): boolean

Parameters

  • key: string

Returns

boolean

public incrementProperty(keyName: string, increment?: number): number

Parameters

  • keyName: string
  • increment?: number optional

Returns

number

public init()

public inject(factoryNameOrType: string, property: string, injectionName: string)

defines an injection or typeInjection

Parameters

  • factoryNameOrType: string
  • property: string
  • injectionName: string

public injectTestHelpers()

This injects the test helpers into the window's scope. If a function of the same name has already been defined it will be cached (so that it can be reset if the helper is removed with unregisterHelper or removeTestHelpers). Any callbacks registered with onInjectHelpers will be called once the helpers have been injected.

public notifyPropertyChange(keyName: string): Observable

Parameters

  • keyName: string

Returns

Observable

public propertyDidChange(keyName: string): Observable

Parameters

  • keyName: string

Returns

Observable

public propertyWillChange(keyName: string): Observable

Parameters

  • keyName: string

Returns

Observable

public register(fullName: string, factory: Function, options?: {})

registers a factory for later injection

Parameters

  • fullName: string

    type:name (e.g., 'model:user')

  • factory: Function

    (e.g., App.Person)

  • options?: {} optional

public removeObserver(key: string, target: any, method: string): Observable

Parameters

  • key: string
  • target: any
  • method: string

Returns

Observable

public removeObserver(key: string, target: any, method: Function): Observable

Parameters

  • key: string
  • target: any
  • method: Function

Returns

Observable

public removeTestHelpers()

This removes all helpers that have been registered, and resets and functions that were overridden by the helpers.

public reset()

Reset the application. This is typically used only in tests.

public set(keyName: string, value: any): Observable

Parameters

  • keyName: string
  • value: any

Returns

Observable

public setProperties(hash: {}): Observable

Parameters

  • hash: {}

Returns

Observable

public setupForTesting()

This hook defers the readiness of the application, so that you can start the app when your tests are ready to run. It also sets the router's location to 'none', so that the window's location will not be modified (preventing both accidental leaking of state between tests and interference with your testing framework).

public toString(): string

Returns a string representation which attempts to provide more information than Javascript's toString typically does, in a generic way for all Ember objects (e.g., "").

Returns

string

public toggleProperty(keyName: string): any

Parameters

  • keyName: string

Returns

any

public willDestroy()