How to use the rsvp.hash 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 mtmacdonald / docgen / source / docgen.js View on Github external
var loadMeta = function () {
        console.log(chalk.green('Loading required JSON metadata files'));
        var files = {
            parameters: readFile(options.input+'/parameters.json'),
            contents: readFile(options.input+'/contents.json'),
        };
        rsvp.hash(files).then(function(files) {
            for(var key in files) {
                if (files.hasOwnProperty(key)) { //ignore prototype
                    try {
                        var file = JSON.parse(files[key]);
                        if (validateJSON(key, file)) {
                            meta[key] = file;
                        } else {
                            mainProcess.exit(1);
                        }
                    } catch (error) {
                        console.log(chalk.red('Error parsing required file: '+key+'.json (invalid JSON)'));
                        if (options.verbose === true) {
                            console.log(chalk.red(error));
                        }
                        mainProcess.exit(1);
                    }
github rancher / ui / app / workload / route.js View on Github external
model(params) {
    return hash({ workload: this.get('store').find('workload', params.workload_id), }).then((hash) => EmberObject.create(hash));
  },
github hashicorp / consul / ui / packages / consul-ui / app / routes / dc / acls / tokens / index.js View on Github external
model(params) {
    const nspace = this.optionalParams().nspace;
    return hash({
      ...this.repo.status({
        items: this.repo.findAllByDatacenter({
          ns: nspace,
          dc: this.modelFor('dc').dc.Name,
        }),
      }),
      nspace: nspace,
      token: this.settings.findBySlug('token'),
      searchProperties: this.queryParams.searchproperty.empty[0],
    });
  }
github hummingbird-me / hummingbird-client / app / routes / groups / group / group-page.js View on Github external
model() {
    const model = this.modelFor('groups.group');
    return RSVP.hash({
      group: model,
      membership: get(model, 'userMembership')
    });
  },
github rancher / ui / lib / alert / addon / new-rule / route.js View on Github external
let newAlert;

    if ( id ) {
      newAlert = globalStore.find('projectAlertRule', id)
        .then( ( alert ) => {
          const cloned = alert.cloneForNew() ;

          return this.loadProjectRule(cloned);
        });
    } else {
      newAlert = this.getNewProjectAlert(projectId);
    }

    const opt = { filter: { projectId } };

    return hash({
      pods:       store.find('pod', null, opt),
      workloads:  store.find('workload', null, opt),
      notifiers:  globalStore.find('notifier', null, { filter: { clusterId } }),
      alertRule:  newAlert,
      alertGroup: globalStore.find('projectAlertGroup', groupId),
    }).then(({
      pods, workloads, notifiers, alertRule, alertGroup
    }) => {
      return {
        pods,
        workloads,
        notifiers,
        alertRule,
        alertGroup,
        mode:  'new',
        level: 'rule',
github ember-cli-deploy / ember-cli-deploy-revision-data / index.js View on Github external
prepare: function(/*context*/) {
        var self = this;

        var promises = {
            data: this._getData(),
            scm: this._getScmData()
        };

        return RSVP.hash(promises)
          .then(function(results) {
            var data = results.data;
            data.scm = results.scm;
            self.log('generated revision data for revision: `' + data.revisionKey + '`', { verbose: true });
            return data;
          })
          .then(function(data) {
            return { revisionData: data };
          })
          .catch(this._errorMessage.bind(this));
      },
github apache / incubator-pinot / thirdeye / thirdeye-frontend / app / actions / metrics.js View on Github external
} = store.metrics;

    const offset = COMPARE_MODE_MAPPING[compareMode] || 1;
    const metricIds = [primaryMetricId, ...relatedMetricIds];
    const baselineStart = moment(currentStart).subtract(offset, 'week').valueOf();
    const baselineEnd = moment(currentEnd).subtract(offset, 'week').valueOf();

    if (!metricIds.length) { return; }
    const promiseHash = metricIds.reduce((hash, id) => {
      const url = `/timeseries/compare/${id}/${currentStart}/${currentEnd}/${baselineStart}/${baselineEnd}?dimension=All&granularity=${granularity}&filters=${encodeURIComponent(filters)}`;
      hash[id] = fetch(url).then(checkStatus);

      return hash;
    }, {});

    return hash(promiseHash)
      .then((metrics) => {
        const filteredMetrics = _.pickBy(metrics, filterMetric);

        metricIds.forEach((id, index) => {
          const filter = filteredMetrics[id];
          if (filter) {
            filter.color = colors[index % colors.length];
          }
        });
        return filteredMetrics;
      })
      .then(res => dispatch(loadRelatedMetricsData(res)))
      .catch(() => {});
  };
}
github tildeio / ember-async-await-helper / addon / components / async-await.js View on Github external
didReceiveArgument(argument) {
    if (argument === this.awaited) { return; }

    this.setProperties({
      awaited: argument,
      isPending: true,
      isSettled: false,
      isResolved: false,
      isRejected: false,
      resolvedValue: UNINITIALIZED(),
      rejectReason: UNINITIALIZED()
    });

    let target = isHash(argument) ? RSVP.hash(argument) : argument;

    Promise.resolve(target).then(
      bind(this, this.didResolve, argument),
      bind(this, this.didReject, argument)
    );
  },
github rancher / ui / app / authenticated / cluster / nodes / templates / route.js View on Github external
model() {
    let globalStore = get(this, 'globalStore');
    return hash({
      machineTemplates: globalStore.findAll('machinetemplate'),
      machineDrivers: globalStore.find('machinedriver', null, {filter: {active: true}}),
    }).then((hash) => {
      return EmberObject.create({
        machineTemplates: hash.machineTemplates,
        machineDrivers: hash.machineDrivers,
      });
    });
  },
});
github discourse / discourse / app / assets / javascripts / discourse / routes / discovery-categories.js View on Github external
_findCategoriesAndTopics(filter) {
    return hash({
      wrappedCategoriesList: PreloadStore.getAndRemove("categories_list"),
      topicsList: PreloadStore.getAndRemove(`topic_list_${filter}`)
    }).then(response => {
      let { wrappedCategoriesList, topicsList } = response;
      let categoriesList =
        wrappedCategoriesList && wrappedCategoriesList.category_list;

      if (categoriesList && topicsList) {
        if (topicsList.topic_list && topicsList.topic_list.top_tags) {
          Site.currentProp("top_tags", topicsList.topic_list.top_tags);
        }

        return EmberObject.create({
          categories: CategoryList.categoriesFrom(
            this.store,
            wrappedCategoriesList