javascripthandlebars.jsember-datahtmlbarsember-1

Ember update causes promises in templates to not wait to resolve


I'm in the middle of an ember 1.12.1 -> 1.13.11 and ember data 1.0.0-beta.19.1 -> 1.13.15 update. I previously had a template:

{{a-component parent=model.parent}}

and a component

parentChanged: on('init', observer('parent', function() {
  var parent = this.get('parent');
  if (parent) {
    parent.get('child').then(child => {
      this.set('child', child);
    });
  }
}))

This worked previously, but after the update, child is undefined after the then call. I had to change it to

parentChanged: on('init', observer('parent', function() {
  var parent = this.get('parent');
  if (parent) {
    parent.then(parent => {
      parent.get('child').then(child => {
        this.set('child', child);
      });
    });
  }
}))

to get it back to working like before the update.

Does anyone know why this is? It seems like the template stops resolving promises after the update.


Solution

  • crosslink https://github.com/emberjs/ember.js/issues/12732

    So after some digging and a repro http://emberjs.jsbin.com/ququdenari/edit?html,js,output, I can't get the initial working case in 1.12.1 working with just promises. This leads me to believe that it may have been the way ember-data was setting up the relationship promises, and since I was updating from 1.0.0-beta.19.1 to 1.13.15, any breaking change is fair game.

    In conclusion, I better understand the issue which was my goal.

    Edit:

    I made an addon ember-resolve-promise-helper to help abstract this issue out of your code.