Having some issues with promises and re-rendering in octane

Hi All,

i’m attempting to use ObjectPromiseProxy to deal with fetching data from ember-data at lower levels of the app outside of the model hook. Before octane this was as simple as following the pattern to create the proxy and then ember would re-render automatically when it resolved the promise.

  promiseObj: computed(function() {
  	return ObjectPromiseProxy.create({
    	promise: resolvingPromise(resultObject)
    });
  }),

This doesn’t appear to be working in octane. The UI never re-renders when the promise resolves.

get promiseObj() {
  	return ObjectPromiseProxy.create({
    	promise: resolvingPromise(resultObject)
    });
  }

It looks like i can hack it to work by just decorating the getter with @computed() but i’m not sure thats really a fix.

I’m not filling this as a bug… yet… because i assume that there is just some other known pattern that works with octane and is the one i should be using. Can anyone direct me how to do it properly? Or is this really a bug?

Here is a twiddle showing the issue. It takes 5 seconds to resolve the promise and you can see that the octane controller doesn’t re-render where the classic controller does.

https://ember-twiddle.com/4a4344310f79688a836b8f6fb4b57f11?openFiles=controllers.application\.js%2C

I haven’t had a chance to dig into why this particular thing isn’t working as expected with ObjectPromiseProxy, but in any case there are more Octane-friendly, mixin-less approaches to the problem. I’ve written up a detailed example of migration from ObjectPromiseProxy to an Octane-ready AsyncData type here, and detailed the implementation of that AsyncData type and the corresponding function/helper here. One note: if you adopt the pattern I show there (which we’ll hopefully be open-sourcing a robust implementation of later this month or early next!), you’ll also want to use the @cached decorator on your getter so that you only end up with one API call for any given set of root state no matter how many times you refer to the result of the getter in your template.

Further reading/discussion on @cached: