DS.PromiseObject Class packages/ember-data/lib/system/promise_proxies.js:35

A PromiseObject is an object that acts like both an Ember.Object and a promise. When the promise is resolved, then the resulting value will be set to the PromiseObject's content property. This makes it easy to create data bindings with the PromiseObject that will be updated when the promise resolves.

For more information see the Ember.PromiseProxyMixin documentation.

Example

1
2
3
4
5
6
7
8
9
var promiseObject = DS.PromiseObject.create({
  promise: $.getJSON('/some/remote/data.json')
});

promiseObject.get('name'); // null

promiseObject.then(function() {
  promiseObject.get('name'); // 'Tomster'
});
Show:

Methods

Properties

Show:

catch

(callback) RSVP.Promise

An alias to the proxied promise's catch.

See RSVP.Promise.catch.

Parameters:

callback Function

Returns:

RSVP.Promise

finally

(callback) RSVP.Promise

An alias to the proxied promise's finally.

See RSVP.Promise.finally.

Parameters:

callback Function

Returns:

RSVP.Promise

then

(callback) RSVP.Promise

An alias to the proxied promise's then.

See RSVP.Promise.then.

Parameters:

callback Function

Returns:

RSVP.Promise
Show:

isFulfilled

Will become true if the proxied promise is fulfilled.

Default: false

isPending

Once the proxied promise has settled this will become false.

Default: true

isRejected

Will become true if the proxied promise is rejected.

Default: false

isSettled

Once the proxied promise has settled this will become true.

Default: false

promise

The promise whose fulfillment value is being proxied by this object.

This property must be specified upon creation, and should not be changed once created.

Example:

1
2
3
Ember.ObjectController.extend(Ember.PromiseProxyMixin).create({
  promise: <thenable>
});

reason

If the proxied promise is rejected this will contain the reason provided.

Default: null