#

API Docs for: v2.11.1
Show: Inherited Protected Private Deprecated

# Ember.PromiseProxyMixin Class

Defined in: `packages/ember-runtime/lib/mixins/promise_proxy.js:40`
Module: ember-runtime
Parent Module: ember

A low level mixin making ObjectProxy promise-aware.

    let ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin);

    let proxy = ObjectPromiseProxy.create({
      promise: Ember.RSVP.cast($.getJSON('/some/remote/data.json'))
    });

    proxy.then(function(json){
       // the json
    }, function(reason) {
       // the reason why you have no json
    });

the proxy has bindable attributes which track the promises life cycle

    proxy.get('isPending')   //=> true
    proxy.get('isSettled')  //=> false
    proxy.get('isRejected')  //=> false
    proxy.get('isFulfilled') //=> false

When the $.getJSON completes, and the promise is fulfilled with json, the life cycle attributes will update accordingly. Note that $.getJSON doesn't return an ECMA specified promise, it is useful to wrap this with an `RSVP.cast` so that it behaves as a spec compliant promise.

    proxy.get('isPending')   //=> false
    proxy.get('isSettled')   //=> true
    proxy.get('isRejected')  //=> false
    proxy.get('isFulfilled') //=> true

As the proxy is an ObjectProxy, and the json now its content, all the json properties will be available directly from the proxy.

    // Assuming the following json:
    {
      firstName: 'Stefan',
      lastName: 'Penner'
    }

    // both properties will accessible on the proxy
    proxy.get('firstName') //=> 'Stefan'
    proxy.get('lastName')  //=> 'Penner'

- Index
- Methods
- Properties

## Item Index

### Methods

- catch
- finally
- then

### Properties

- isFulfilled
- isPending
- isRejected
- isSettled
- promise
- reason

## Methods

### `catch`

(

- `callback`

)
RSVP.Promise public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:183`

Available since 1.3.0

An alias to the proxied promise's `catch`.

See RSVP.Promise.catch.

#### Parameters:

- `callback` Function

#### Returns:

RSVP.Promise:

### `finally`

(

- `callback`

)
RSVP.Promise public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:196`

Available since 1.3.0

An alias to the proxied promise's `finally`.

See RSVP.Promise.finally.

#### Parameters:

- `callback` Function

#### Returns:

RSVP.Promise:

### `then`

(

- `callback`

)
RSVP.Promise public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:171`

An alias to the proxied promise's `then`.

See RSVP.Promise.then.

#### Parameters:

- `callback` Function

#### Returns:

RSVP.Promise:

## Properties

### `isFulfilled`

Unknown public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:136`

Will become `true` if the proxied promise is fulfilled.

Default: false

### `isPending`

Unknown public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:109`

Once the proxied promise has settled this will become `false`.

Default: true

### `isRejected`

Unknown public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:127`

Will become `true` if the proxied promise is rejected.

Default: false

### `isSettled`

Unknown public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:118`

Once the proxied promise has settled this will become `true`.

Default: false

### `promise`

Unknown public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:145`

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:

    Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({
      promise: <thenable>
    });

### `reason`

Unknown public

Defined in `packages/ember-runtime/lib/mixins/promise_proxy.js:99`

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

Default: null