How to use the ember-concurrency.all function in ember-concurrency

To help you get started, we’ve selected a few ember-concurrency examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TryGhost / Ghost-Admin / app / components / gh-uploader.js View on Github external
this._reset();
        this.onStart(files);

        // NOTE: for...of loop results in a transpilation that errors in Edge,
        // once we drop IE11 support we should be able to use native for...of
        for (let i = 0; i < files.length; i += 1) {
            let file = files[i];
            let tracker = UploadTracker.create({file});

            this._uploadTrackers.pushObject(tracker);
            uploads.push(this._uploadFile.perform(tracker, file, i));
        }

        // populates this.errors and this.uploadUrls
        yield all(uploads);

        if (!isEmpty(this.errors)) {
            this.onFailed(this.errors);
        }

        this.onComplete(this.uploadUrls);
    }).drop(),
github offirgolan / ember-data-copyable / addon / mixins / copyable.js View on Github external
? relOptions.deep
          : deep;

      if (meta.kind === 'belongsTo') {
        if (value && value.get(IS_COPYABLE)) {
          attrs[name] = yield value
            .get(COPY_TASK)
            .perform(deepRel, relOptions, _meta);
        } else {
          attrs[name] = value;
        }
      } else if (meta.kind === 'hasMany') {
        const firstObject = value.get('firstObject');

        if (firstObject && firstObject.get(IS_COPYABLE)) {
          attrs[name] = yield all(
            value
              .getEach(COPY_TASK)
              .invoke('perform', deepRel, relOptions, _meta)
          );
        } else {
          attrs[name] = value;
        }
      }
    }

    // Build the final attrs pojo by merging otherAttributes, the copied
    // attributes, and ant overwrites specified.
    attrs = assign(this.getProperties(otherAttributes), attrs, overwrite);

    // Set the properties on the model
    model.setProperties(attrs);
github HospitalRun / hospitalrun-frontend / app / patients / delete / controller.js View on Github external
deleteManyTask: task(function* (manyArray) {
    if (!manyArray) {
      return;
    }
    let resolvedArray = yield manyArray;
    if (isEmpty(resolvedArray)) {
      // empty array: no records to delete
      return;
    }
    let deleteRecordTask = this.get('deleteRecordTask');
    let archivePromises = [];
    resolvedArray.forEach((recordToDelete) => {
      archivePromises.push(deleteRecordTask.perform(recordToDelete));
    });
    return yield all(archivePromises, 'async array deletion');
  }).group('deleting'),
github m1nl / pompa / app / controllers / campaigns / campaign / index.js View on Github external
let childTasks = [];

    scenarios.forEach(function(scenario) {
      scenario.set('event-query-params', {
        include: ['victim', 'goal'],
        page: { number: 1, size: MAX_EVENTS },
        sort: ['-reported_date', 'id'],
      });

      childTasks.push(scenario.belongsTo('report').reload());
      childTasks.push(scenario.hasMany('events').reload());
    });

    this.set('scenarios', scenarios);

    yield all(childTasks);
  }).restartable(),
  refreshTask: task(function * () {
github HospitalRun / hospitalrun-frontend / app / patients / delete / controller.js View on Github external
deleteInvoicesTask: task(function* (patientInvoices) {
    let invoices = yield patientInvoices;
    let lineItems = yield all(invoices.mapBy('lineItems'));
    let lineItemDetails = yield all(lineItems.mapBy('details'));
    return yield all([
      this.deleteMany(invoices),
      this.deleteMany(lineItems),
      this.deleteMany(lineItemDetails)
    ]);
  }).group('deleting'),
github hummingbird-me / hummingbird-client / app / controllers / settings / notifications.js View on Github external
updateSettingsTask: task(function* () {
    const settingsTasks = [];
    get(this, 'dirtySettings').forEach((setting) => {
      settingsTasks.push(get(this, 'updateSettingTask').perform(setting));
    });
    yield get(this, 'session.account').save();
    yield all(settingsTasks).then((results) => {
      if (isEmpty(results.filter(result => result === undefined))) {
        get(this, 'notify').success('Your notification settings were updated.');
      }
    });
  }).drop(),
github HospitalRun / hospitalrun-frontend / app / patients / delete / controller.js View on Github external
let procCharges = procedures.get('charges');
      let labCharges = labs.get('charges');
      let imagingCharges = imaging.get('charges');
      let visitCharges = visit.get('charges');
      pendingTasks.push(this.deleteMany(labs));
      pendingTasks.push(this.deleteMany(labCharges));
      pendingTasks.push(this.deleteMany(visit.get('patientNotes')));
      pendingTasks.push(this.deleteMany(visit.get('vitals')));
      pendingTasks.push(this.deleteMany(procedures));
      pendingTasks.push(this.deleteMany(procCharges));
      pendingTasks.push(this.deleteMany(visit.get('medication')));
      pendingTasks.push(this.deleteMany(imaging));
      pendingTasks.push(this.deleteMany(imagingCharges));
      pendingTasks.push(this.deleteMany(visitCharges));
    });
    yield all(pendingTasks);
    return yield this.deleteMany(visits);
  }).group('deleting'),
github CenterForOpenScience / ember-osf-preprints / app / components / chronos-submission-panel / component.js View on Github external
_updateChronosSubmissions: task(function* () {
        if (this.get('isOpen')) {
            this.set('isOpen', false);
            return;
        } else {
            this.set('isOpen', true);
        }
        const submissions = yield this.get('store').peekAll('chronos-submission');
        const childTasks = [];
        submissions.forEach(function (item) {
            if (item.get('preprint.id') === this.get('preprint.id')) {
                childTasks.push(this.get('_updateStatus').perform(item));
            }
        }.bind(this));
        yield all(childTasks);
    }).drop(),
    /*
github CenterForOpenScience / ember-osf-web / app / guid-user / quickfiles / controller.ts View on Github external
deleteFiles = task(function *(this: UserQuickfiles, files: File[]) {
        const deleteFile = this.get('deleteFile');

        yield all(files.map(file => deleteFile.perform(file)));
    });
github CenterForOpenScience / ember-osf-web / lib / osf-components / addon / components / citation-viewer / component.ts View on Github external
loadDefaultCitations: task(function *(this: CitationViewer) {
        const responses: SingleResourceDocument[] = yield all(
            defaultCitations.map(
                c => this.currentUser.authenticatedAJAX({ url: citationUrl(this.citable, c.id) }),
            ),
        );
        return responses.map((r, i) => ({
            ...defaultCitations[i],
            citation: r.data.attributes!.citation,
        }));
    }).on('init'),