How to use the rsvp.allSettled 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 ember-engines / ember-asset-loader / addon / services / asset-loader.js View on Github external
loadBundle(name, retryLoad) {
    const cachedPromise = this._getFromCache('bundle', name, retryLoad === RETRY_LOAD_SECRET);

    if (cachedPromise) {
      return cachedPromise;
    }

    const bundle = this._getBundle(name);

    const dependencies = bundle.dependencies || [];
    const dependencyPromises = dependencies.map((dependency) => this.loadBundle(dependency, retryLoad));

    const assets = bundle.assets || [];
    const assetPromises = assets.map((asset) => this.loadAsset(asset, retryLoad));

    const bundlePromise = RSVP.allSettled([ ...dependencyPromises, ...assetPromises ]);

    const bundleWithFail = bundlePromise.then((promises) => {
      const rejects = promises.filter((promise) => promise.state === 'rejected');
      const errors = rejects.map((reject) => reject.reason);

      if (errors.length) {
        // Evict rejected promise.
        this._getFromCache('bundle', name, true);
        throw new BundleLoadError(this, name, errors);
      }

      return name;
    });

    return this._setInCache('bundle', name, bundleWithFail);
  },
github hashicorp / vault / ui / app / adapters / transform.js View on Github external
fetchByQuery(store, query) {
    const { id, backend } = query;
    const queryAjax = this.ajax(this.urlForTransformations(backend, id), 'GET', this.optionsForQuery(id));

    return allSettled([queryAjax]).then(results => {
      // query result 404d, so throw the adapterError
      if (!results[0].value) {
        throw results[0].reason;
      }
      let resp = {
        id,
        name: id,
        backend,
        data: {},
      };

      results.forEach(result => {
        if (result.value) {
          if (result.value.data.roles) {
            // TODO: Check if this is needed and remove if not
            resp.data = assign({}, resp.data, { zero_address_roles: result.value.data.roles });
github rancher / ui / app / authenticated / cluster / edit / route.js View on Github external
let store = this.get('clusterStore');
    let catalog = this.get('catalog');
    let deps = [];

    let cluster = this.modelFor('authenticated.cluster').clone();
    if ( cluster.systemStacks === null ) {
      let def = JSON.parse(this.get(`settings.${C.SETTING.CLUSTER_TEMPLATE}`)) || {};
      cluster.set('systemStacks', (def.systemStacks||[]).map((stack) => {
        stack.type = 'stackConfiguration';
        let extInfo = parseExternalId(stack.externalId);
        deps.push(catalog.fetchTemplate(extInfo.templateId, false));
        return store.createRecord(stack);
      }));
    }

    return allSettled(deps).then(() => {
      return this.get('catalog').fetchTemplates({plusInfra: true}).then((resp) => {
        resp.cluster = cluster;
        return resp;
      });
    });
  },
});
github hummingbird-me / hummingbird-client / app / components / users / edit-profile / favorites.js View on Github external
getAllFavorites: task(function* () {
    const anime = get(this, 'getFavorites').perform('Anime');
    const manga = get(this, 'getFavorites').perform('Manga');
    const chars = get(this, 'getFavorites').perform('Character');
    return yield RSVP.allSettled([anime, manga, chars], 'Get Favorites');
  }).drop().cancelOn('willDestroyElement'),
github runspired / ember-cli-toolbelts / lib / toolbelt / index.js View on Github external
removeDependenciesFromProject: function(packages) {
    var uninstallText = (packages.length > 1) ? 'uninstall dependencies' : 'uninstall dependency';
    var packageArray = packages.map(function(pkg) { return pkg.name; });

    this._writeStatusToUI(chalk.green, uninstallText, packageArray.join(', '));

    var promises = packageArray.map(function(name) {
      return runCommand('npm uninstall --save ' + name)();
    });
    return RSVP.allSettled(promises);
  }
github ef4 / ember-handoff / addon / models / server-page.js View on Github external
appendTo($element) {
    let assets = this.get('assets');

    if (this.get('dom')) {
      this.get('dom').forEach(node => {
        node.remove();
        $element[0].appendChild(assets.cloneOrImport(node));
      });
      return RSVP.resolve();
    }

    let scriptsPromise = assets.applyScripts(this.get('pieces.scripts'));
    Array.from(this.get('pieces.body').childNodes).forEach(child => {
      $element[0].appendChild(assets.cloneOrImport(child));
    });
    return RSVP.allSettled([assets.applyStyles(this.get('pieces.styles'), $element[0]), scriptsPromise]);
  }
});
github offirgolan / ember-cp-validations / addon / validations / result-collection.js View on Github external
cycleBreaker(function() {
      return RSVP.allSettled(
        compact(
          flatten([
            this.get('_contentResults').getEach('_promise'),
            this.getEach('_promise')
          ])
        )
      );
    })
  ).readOnly(),
github isleofcode / corber / lib / commands / start.js View on Github external
getInstalledDevices(platforms) {
    let promises = [];

    if (platforms.includes('ios')) {
      promises.push(listIOSDevices());
      promises.push(listIOSEmulators());
    }

    if (platforms.includes('android')) {
      promises.push(listAndroidDevices());
      promises.push(listAndroidEmulators());
    }

    return RSVP.allSettled(promises).then((results) => {
      return results.filter((r) => r.state === 'fulfilled')
        .reduce((arr, result) => arr.concat(result.value), []);
    });
  },
github apache / incubator-pinot / thirdeye / thirdeye-frontend / app / pods / manage / alert / tune / route.js View on Github external
const fetchSeverityScores = (anomalyIds) => {
  if (anomalyIds.length) {
    const anomalyPromiseHash = anomalyIds.map((id) => {
      return RSVP.hash({
        id,
        score: fetch(`/dashboard/anomalies/score/${id}`).then(checkStatus)
      });
    });
    return RSVP.allSettled(anomalyPromiseHash);
  } else {
    return RSVP.resolve([]);
  }
};