How to use the rsvp.all function in rsvp

To help you get started, we’ve selected a few rsvp 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 crotwell / seisplotjs / src / mseedarchive.js View on Github external
util.log("no data: status="+fetchResponse.status+" "+fetchResponse.url);
          return [];
        }
      } else if (fetchResponse.status === 404 ) {
        return []; // empty array means no data
      } else {
        // $FlowFixMe
        throw new Error("fetch error: "+fetchResponse.ok+" "+fetchResponse.status+" "+fetchResponse.url);
      }
    }).catch(err => {
      util.log("caught fetch err, continuing with empty: "+err);
      return [];
    });
  });

  return RSVP.all(promiseArray).then(pArray => {
      let dataRecords: Array = [];
      pArray.forEach(p => {
        dataRecords = dataRecords.concat(p);
      });
      return dataRecords;
  });
}
github ilios / frontend / app / components / session-copy.js View on Github external
let learningMaterialsToCopy = yield sessionToCopy.get('learningMaterials');
    for (let i = 0; i < learningMaterialsToCopy.length; i++){
      let learningMaterialToCopy = learningMaterialsToCopy.toArray()[i];
      let lm = yield learningMaterialToCopy.get('learningMaterial');
      let learningMaterial = store.createRecord(
        'sessionLearningMaterial',
        learningMaterialToCopy.getProperties('notes', 'required', 'publicNotes', 'position')
      );
      learningMaterial.set('learningMaterial', lm);
      learningMaterial.set('session', session);
      toSave.pushObject(learningMaterial);
    }

    // save the session first to fill out relationships with the session id
    yield session.save();
    yield all(toSave.invoke('save'));

    //parse objectives last because it is a many2many relationship
    //and ember data tries to save it too soon
    let relatedObjectives = yield sessionToCopy.get('objectives');
    let objectivesToCopy = relatedObjectives.sortBy('id');
    for (let i = 0; i < objectivesToCopy.length; i++){
      let objectiveToCopy = objectivesToCopy.toArray()[i];
      let meshDescriptors = yield objectiveToCopy.get('meshDescriptors');
      let objective = store.createRecord(
        'objective',
        objectiveToCopy.getProperties('title', 'position')
      );
      objective.set('meshDescriptors', meshDescriptors);
      objective.set('sessions', [session]);
      //save each objective as it is created to preserve to sequence order of objectives by id
      yield objective.save();
github emberjs / data / packages / unpublished-test-infra / addon-test-support / async.js View on Github external
export function asyncEqual(a, b, message) {
  return all([resolve(a), resolve(b)]).then(
    this.wait(array => {
      let actual = array[0];
      let expected = array[1];
      let result = actual === expected;

      this.pushResult({ result, actual, expected, message });
    })
  );
}
github fortunejs / fortune / test / all.js View on Github external
.send(body)
            .expect('Content-Type', /json/)
            .expect(201)
            .end(function (error, response) {
              should.not.exist(error);
              var resources = JSON.parse(response.text)[key];
              ids[key] = ids[key] || [];
              resources.forEach(function (resource) {
                ids[key].push(resource.id);
              });
              resolve();
            });
        }));
      });

      RSVP.all(createResources).then(function () {
        done();
      }, function () {
        throw new Error('Failed to create resources.');
      });

    });
github ember-intl / ember-intl / lib / writer.js View on Github external
return RSVP.all(promises).then(resolve, reject);
			}

			file = config.prelude(key) + entries.map(serializeEntry).join('\n') + config.footer;

			writefile({
				data:     file,
				filepath: dest,
				minify:   minify
			}, resolve, reject);

			console.log('wrote locale data to: ' + dest);
		});
	}.bind(this));

	return RSVP.all(writePromises);
}
github fortunejs / fortune / lib / route.js View on Github external
var location = options.baseUrl + '/';
      location += !!options.namespace ? options.namespace + '/' : '';
      location += collection + '/' + primaryResources.map(function (resource) {
        return resource.id;
      }).join(',');
      res.set('Location', location);

      if (Object.keys(linkedResources).length) {
        var promises = [];

        body.linked = linkedResources;
        primaryResources.forEach(function (resource) {
          promises.push(adapter.find(name, resource.id));
        });

        RSVP.all(promises).then(function (resources) {
          return RSVP.all(resources.map(function (resource) {
            return afterTransform(resource, req, res);
          }));
        }).then(function (resources) {
          body[collection] = resources;
          sendResponse(req, res, 201, body);
        });
      } else {
        body[collection] = primaryResources;
        sendResponse(req, res, 201, body);
      }
    }, function (error) {
      sendError(req, res, 500, error);
github code-corps / code-corps-ember / app / controllers / project / tasks / new.js View on Github external
async _saveSkills(task) {
    let unsavedTaskSkills = get(this, 'unsavedTaskSkills');
    let promises = unsavedTaskSkills.map((skill) => this._createTaskSkill(skill, task));
    return RSVP.all(promises).then(() => task);
  }
});
github rancher / ui / app / components / input-edit-password / component.js View on Github external
return get(this, 'globalStore').findAll('token').then((tokens) => {
            const promises = [];

            tokens.forEach((token) => {
              if ( !token.current ) {
                promises.push(token.delete());
              }
            });

            return all(promises).catch(() => resolve());
          });
        } else {
github hashicorp / nomad / ui / app / routes / jobs / job / deployments.js View on Github external
model() {
    const job = this.modelFor('jobs.job');
    return job && RSVP.all([job.get('deployments'), job.get('versions')]).then(() => job);
  }
github ilios / frontend / app / components / detail-cohorts.js View on Github external
course.get('objectives').then(objectives => {
            RSVP.all(objectives.invoke('removeParentWithProgramYears', programYearsToRemove)).then(()=> {
              course.save().then(()=>{
                this.set('isManaging', false);
                this.set('bufferedCohorts', []);
                this.set('isSaving', false);
              });
            });
          });