Ember Use findBy on PromiseArray

How to do a findBy on an PromiseArray in Ember?

export default Ember.ObjectController.extend({

  products: function() {
    return this.store.find('products');
  }.property(),

  product: function() {
    return this.get('products').findBy('default', true);
  }.property('products.isFulfilled')

});

The trick is to use the isFulfilled flag so it does not throw an error.

Ember < 2.0.0 (don’t now the exact version)

Happy coding! – Found a mistake or a typo? Please submit a PR to my GitHub-repo.

Get my next post right in your inbox via Blogsend
(I don't get your email address so I can't spam you)

Like this post? Follow @adriaanvrossum on Twitter