Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4838

Using promises with computed properties?

$
0
0

@tsteuwer wrote:

Hey everyone,

I'm trying to use a computed property to return models when an array of ids changes on a service. It looks like this:

people: computed('ids', function() {
    const promises = this.get('ids').map(id => {
      return this.get('store').findRecord('people', id);
    });

    return new Ember.RSVP.Promise((resolve) => {
      Ember.RSVP.allSettled(promises).then(responses => {
        const results = [];
        responses.forEach(prom => {
          if (prom.state === 'fulfilled') {
            results.push(prom);
          }
        });
        resolve(results);
      });
    });
})

However, this does not end up showing up in the template. Any ideas why?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4838

Trending Articles