1

The Ember documentation describes PromiseProxyMixin as:

A low level mixin making ObjectProxy, ObjectController or ArrayControllers promise-aware.

(Note it does not mention Controller.)

I have been using the PromiseProxyMixin in a ModalController that was originally extended from Ember.ObjectController.

Now that ObjectController is deprecated (Ember 1.11), I have converted this controller to extend Ember.Controller and it no longer works as expected.

Specifically, the properties of the object that are returned to the promise property are not automatically set in the Controller (as they were in an ObjectController.

My isFulfilled observer is still firing, but the properties that should be merged from the returned object are not set.

The documentation also states:

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

So I guess I'll just have to manually set these properties from now on?

real_ate
  • 10,861
  • 3
  • 27
  • 48
Kevin Boucher
  • 16,426
  • 3
  • 48
  • 55

2 Answers2

1

Because the merging of properties returned by the Promise no longer happens automatically my options seemed to be:

  1. Convert the Controller back to ObjectController (wrong direction)
  2. Manually merge the properties of the object returned by the Promise (this might make sense if I did it in a generic MyProxyMixin or some-such)
  3. Convert Controller to ObjectProxy (not sure about this)
  4. Use Ember's ProxyMixin

I would've preferred #4, but there have been some gyrations around this mixin (it was enabled as an Ember.FEATURE for a little while but appears to have been made private again.)

Ultimately I opted for #2. (I just updated my code to copy the properties I needed to the Controller.)

Kevin Boucher
  • 16,426
  • 3
  • 48
  • 55
0

PromiseProxyMixin hasn't been deprecated and is used in other contexts. The current API docs on git makes no mention of controllers. The wording your looking at has changed, I would assume it's safe to just keep using.

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'
Kit Sunde
  • 35,972
  • 25
  • 125
  • 179
  • _PromiseProxyMixin hasn't been deprecated_ True, but `ObjectController` is and for whatever reason the automatic merging of properties returned by the `Promise` does not occur with `Controller`. The rest of the functionality of `PromiseProxyMixin` works though. I was able to observe `isFulfilled` w/o incident. – Kevin Boucher Aug 11 '15 at 21:19