Skip to content

Commit

Permalink
Replace usage of private PromiseArray with ember-concurrency task
Browse files Browse the repository at this point in the history
  • Loading branch information
nickschot committed Aug 15, 2020
1 parent 00d5ba2 commit 159a185
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions addon/components/tag-post-list.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';

import DS from 'ember-data';
import { task } from 'ember-concurrency';

const topPostCount = 3;

Expand All @@ -23,14 +22,14 @@ export default class TagPostList extends Component {
super(...arguments);

let ids = this.args.tag.hasMany('posts').ids().slice(0, topPostCount);

let promise = Promise.all(ids.map(id => this.store.findRecord('content', id)));

this.topPosts = DS.PromiseArray.create({
promise,
});
this.loadTopPostsTask.perform(ids);
}

@(task(function*(ids){
this.topPosts = yield Promise.all(ids.map(id => this.store.findRecord('content', id)));
}).restartable())
loadTopPostsTask;

get titleId() {
return `${this.args.tag.id}-tag`;
}
Expand Down

0 comments on commit 159a185

Please sign in to comment.