Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace usage of private PromiseArray with ember-concurrency task #76

Merged
merged 1 commit into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions addon/components/tag-post-list.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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';
import withTestWaiter from 'ember-concurrency-test-waiter/with-test-waiter';

const topPostCount = 3;

Expand All @@ -23,14 +23,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);
}

@(withTestWaiter(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
185 changes: 185 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"ember-cli-htmlbars": "^4.2.3",
"ember-composable-helpers": "^3.1.1",
"ember-concurrency": "^1.2.1",
"ember-concurrency-test-waiter": "^0.3.2",
"ember-moment": "^8.0.0",
"ember-styleguide": "^4.2.1",
"ember-svg-jar": "^2.2.3"
Expand Down