From 158816f6a733ab72189ef9d99a5ecf20234683b2 Mon Sep 17 00:00:00 2001 From: nickschot Date: Mon, 17 Aug 2020 13:18:00 +0200 Subject: [PATCH] Replace usage of private PromiseArray with ember-concurrency task --- addon/components/tag-post-list.js | 16 +-- package-lock.json | 185 ++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 194 insertions(+), 8 deletions(-) diff --git a/addon/components/tag-post-list.js b/addon/components/tag-post-list.js index 8954040..76dc122 100644 --- a/addon/components/tag-post-list.js +++ b/addon/components/tag-post-list.js @@ -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; @@ -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`; } diff --git a/package-lock.json b/package-lock.json index 91cd78e..fdbcff5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13637,6 +13637,191 @@ "ember-maybe-import-regenerator": "^0.1.6" } }, + "ember-concurrency-test-waiter": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/ember-concurrency-test-waiter/-/ember-concurrency-test-waiter-0.3.2.tgz", + "integrity": "sha512-7AkltohwutNhwknycqd7sF0bh6MhkJKB3WdyHpV4RnPMZzILaIGfFHsosy33eMQ3sC46iwA7QE9TSOMEQZOCGQ==", + "dev": true, + "requires": { + "ember-cli-babel": "^6.6.0" + }, + "dependencies": { + "amd-name-resolver": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/amd-name-resolver/-/amd-name-resolver-1.2.0.tgz", + "integrity": "sha512-hlSTWGS1t6/xq5YCed7YALg7tKZL3rkl7UwEZ/eCIkn8JxmM6fU6Qs/1hwtjQqfuYxlffuUcgYEm0f5xP4YKaA==", + "dev": true, + "requires": { + "ensure-posix-path": "^1.0.1" + } + }, + "babel-plugin-debug-macros": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.2.0.tgz", + "integrity": "sha512-Wpmw4TbhR3Eq2t3W51eBAQSdKlr+uAyF0GI4GtPfMCD12Y4cIdpKC9l0RjNTH/P9isFypSqqewMPm7//fnZlNA==", + "dev": true, + "requires": { + "semver": "^5.3.0" + } + }, + "broccoli-babel-transpiler": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/broccoli-babel-transpiler/-/broccoli-babel-transpiler-6.5.1.tgz", + "integrity": "sha512-w6GcnkxvHcNCte5FcLGEG1hUdQvlfvSN/6PtGWU/otg69Ugk8rUk51h41R0Ugoc+TNxyeFG1opRt2RlA87XzNw==", + "dev": true, + "requires": { + "babel-core": "^6.26.0", + "broccoli-funnel": "^2.0.1", + "broccoli-merge-trees": "^2.0.0", + "broccoli-persistent-filter": "^1.4.3", + "clone": "^2.0.0", + "hash-for-dep": "^1.2.3", + "heimdalljs-logger": "^0.1.7", + "json-stable-stringify": "^1.0.0", + "rsvp": "^4.8.2", + "workerpool": "^2.3.0" + } + }, + "broccoli-funnel": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/broccoli-funnel/-/broccoli-funnel-2.0.2.tgz", + "integrity": "sha512-/vDTqtv7ipjEZQOVqO4vGDVAOZyuYzQ/EgGoyewfOgh1M7IQAToBKZI0oAQPgMBeFPPlIbfMuAngk+ohPBuaHQ==", + "dev": true, + "requires": { + "array-equal": "^1.0.0", + "blank-object": "^1.0.1", + "broccoli-plugin": "^1.3.0", + "debug": "^2.2.0", + "fast-ordered-set": "^1.0.0", + "fs-tree-diff": "^0.5.3", + "heimdalljs": "^0.2.0", + "minimatch": "^3.0.0", + "mkdirp": "^0.5.0", + "path-posix": "^1.0.0", + "rimraf": "^2.4.3", + "symlink-or-copy": "^1.0.0", + "walk-sync": "^0.3.1" + } + }, + "broccoli-merge-trees": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/broccoli-merge-trees/-/broccoli-merge-trees-2.0.1.tgz", + "integrity": "sha512-WjaexJ+I8BxP5V5RNn6um/qDRSmKoiBC/QkRi79FT9ClHfldxRyCDs9mcV7mmoaPlsshmmPaUz5jdtcKA6DClQ==", + "dev": true, + "requires": { + "broccoli-plugin": "^1.3.0", + "merge-trees": "^1.0.1" + } + }, + "broccoli-persistent-filter": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/broccoli-persistent-filter/-/broccoli-persistent-filter-1.4.6.tgz", + "integrity": "sha512-0RejLwoC95kv4kta8KAa+FmECJCK78Qgm8SRDEK7YyU0N9Cx6KpY3UCDy9WELl3mCXLN8TokNxc7/hp3lL4lfw==", + "dev": true, + "requires": { + "async-disk-cache": "^1.2.1", + "async-promise-queue": "^1.0.3", + "broccoli-plugin": "^1.0.0", + "fs-tree-diff": "^0.5.2", + "hash-for-dep": "^1.0.2", + "heimdalljs": "^0.2.1", + "heimdalljs-logger": "^0.1.7", + "mkdirp": "^0.5.1", + "promise-map-series": "^0.2.1", + "rimraf": "^2.6.1", + "rsvp": "^3.0.18", + "symlink-or-copy": "^1.0.1", + "walk-sync": "^0.3.1" + }, + "dependencies": { + "rsvp": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz", + "integrity": "sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==", + "dev": true + } + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ember-cli-babel": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz", + "integrity": "sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==", + "dev": true, + "requires": { + "amd-name-resolver": "1.2.0", + "babel-plugin-debug-macros": "^0.2.0-beta.6", + "babel-plugin-ember-modules-api-polyfill": "^2.6.0", + "babel-plugin-transform-es2015-modules-amd": "^6.24.0", + "babel-polyfill": "^6.26.0", + "babel-preset-env": "^1.7.0", + "broccoli-babel-transpiler": "^6.5.0", + "broccoli-debug": "^0.6.4", + "broccoli-funnel": "^2.0.0", + "broccoli-source": "^1.1.0", + "clone": "^2.0.0", + "ember-cli-version-checker": "^2.1.2", + "semver": "^5.5.0" + } + }, + "ember-cli-version-checker": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ember-cli-version-checker/-/ember-cli-version-checker-2.2.0.tgz", + "integrity": "sha512-G+KtYIVlSOWGcNaTFHk76xR4GdzDLzAS4uxZUKdASuFX0KJE43C6DaqL+y3VTpUFLI2FIkAS6HZ4I1YBi+S3hg==", + "dev": true, + "requires": { + "resolve": "^1.3.3", + "semver": "^5.3.0" + } + }, + "merge-trees": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-trees/-/merge-trees-1.0.1.tgz", + "integrity": "sha1-zL5nRWl4f53vF/1G5lJfVwC70j4=", + "dev": true, + "requires": { + "can-symlink": "^1.0.0", + "fs-tree-diff": "^0.5.4", + "heimdalljs": "^0.2.1", + "heimdalljs-logger": "^0.1.7", + "rimraf": "^2.4.3", + "symlink-or-copy": "^1.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "workerpool": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-2.3.3.tgz", + "integrity": "sha512-L1ovlYHp6UObYqElXXpbd214GgbEKDED0d3sj7pRdFXjNkb2+un/AUcCkceHizO0IVI6SOGGncrcjozruCkRgA==", + "dev": true, + "requires": { + "object-assign": "4.1.1" + } + } + } + }, "ember-data": { "version": "3.17.0", "resolved": "https://registry.npmjs.org/ember-data/-/ember-data-3.17.0.tgz", diff --git a/package.json b/package.json index 1236e38..bb5785f 100644 --- a/package.json +++ b/package.json @@ -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"