ember-concurrency
ember-concurrency copied to clipboard
Feature Request: Add `waitForEachProperty` on array
Consider dropbox
or google drive
as a use case example.
In our app, we allow uploading files and it may take some time, and when all files are uploaded we want to show modal window which asks the user if he/she wants to share those files.
export default class UploadFilesComponent extends Component {
@service('files') filesService;
@task
uploadFiles = function* (files) {
const result = yield this.filesService.upload(files);
yield waitForEachProperty(result, 'isUploaded', x => x === true);
setProperties(this, {
uploadedFiles: result,
showShareUploadedFilesModal: true,
});
}
}
The same functionality could be easily accomplished just by using regular for
loop
for (let i = 0; i < result.length; i++) {
yield waitForProperty(result[i], 'isUploaded', x => x === true);
}
but for me it would be much better to use something like
yield waitForEachProperty(result, 'isUploaded', x => x === true);