How to use the rsvp.Promise.resolve 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 discourse / discourse / app / assets / javascripts / discourse / widgets / widget.js.es6 View on Github external
if (view) {
      const method = view.get(name);
      if (!method) {
        // eslint-disable-next-line no-console
        console.warn(`${name} not found`);
        return;
      }

      if (typeof method === "string") {
        view[method](param);
        promise = Promise.resolve();
      } else {
        const target = view.get("target") || view;
        promise = method.call(target, param);
        if (!promise || !promise.then) {
          promise = Promise.resolve(promise);
        }
      }
    }

    return this.rerenderResult(() => promise);
  }
github tildeio / router.js / lib / router / handler-info / resolved-handler-info.js View on Github external
resolve(shouldContinue, payload) {
    // A ResolvedHandlerInfo just resolved with itself.
    if (payload && payload.resolvedModels) {
      payload.resolvedModels[this.name] = this.context;
    }
    return Promise.resolve(this, this.promiseLabel('Resolve'));
  }
github discourse / discourse / app / assets / javascripts / discourse / models / store.js.es6 View on Github external
destroyRecord(type, record) {
    // If the record is new, don't perform an Ajax call
    if (record.get("isNew")) {
      removeMap(type, record.get("id"));
      return Promise.resolve(true);
    }

    return this.adapterFor(type)
      .destroyRecord(this, type, record)
      .then(function(result) {
        removeMap(type, record.get("id"));
        return result;
      });
  },
github emberjs / data / packages / store / addon / -private / system / fetch-manager.ts View on Github external
let operation = options[SaveOp];

    // TODO We have to cast due to our reliance on this private property
    // this will be refactored away once we change our pending API to be identifier based
    let internalModel = ((snapshot as unknown) as PrivateSnapshot)._internalModel;
    let modelName = snapshot.modelName;
    let store = this._store;
    let modelClass = store.modelFor(modelName);

    assert(`You tried to update a record but you have no adapter (for ${modelName})`, adapter);
    assert(
      `You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`,
      typeof adapter[operation] === 'function'
    );

    let promise = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));
    let serializer = store.serializerFor(modelName);
    let label = `DS: Extract and notify about ${operation} completion of ${internalModel}`;

    assert(
      `Your adapter's '${operation}' method must return a value, but it returned 'undefined'`,
      promise !== undefined
    );

    promise = guardDestroyedStore(promise, store, label);
    promise = _guard(promise, _bind(_objectIsAlive, internalModel));

    promise = promise.then(
      adapterPayload => {
        if (adapterPayload) {
          return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);
        }
github projectfluent / fluent.js / lib / l20n / context.js View on Github external
if (!entity) {
    debug(id, 'missing from', lang);
    return this._fetchResources(supported.slice(1)).then(
      this._getFallback.bind(this, id, args),
      function(err) {
        debug(err);
        // XXX comply to Gaia's l10n.js behavior for now;
        // return id in the future
        return Promise.resolve(null);
      });
  } else {
    debug(id, 'found in', lang);
    // XXX format the entity here, passing ctx and args
    // XXX handle compiler's runtime errors and fall back if needed
    // return entity.format(this, args);
    return Promise.resolve(entity);
  }
};
github discourse / discourse / app / assets / javascripts / discourse / app / routes / build-category-route.js View on Github external
_createSubcategoryList(category) {
      this._categoryList = null;

      if (category.isParent && category.show_subcategory_list) {
        return CategoryList.listForParent(this.store, category).then(
          (list) => (this._categoryList = list)
        );
      }

      // If we're not loading a subcategory list just resolve
      return Promise.resolve();
    },
github sir-dunxalot / ember-tooltips / tests / helpers / module-for-acceptance.js View on Github external
afterEach() {
      let afterEach = options.afterEach && options.afterEach.apply(this, arguments);

      return Promise.resolve(afterEach).then(() => destroyApp(this.application));
    },
  });
github offirgolan / ember-cp-validations / addon / validations / factory.js View on Github external
function validationReturnValueHandler(attribute, value, model, validator) {
  let result;
  let commonProps = {
    model,
    attribute,
    _validator: validator
  };

  if (isPromise(value)) {
    result = ValidationResult.create(commonProps, {
      _promise: Promise.resolve(value)
    });
  } else {
    result = ValidationResult.create(commonProps);
    result.update(value);
  }

  return result;
}
github discourse / discourse / app / assets / javascripts / select-kit / addon / components / select-kit.js View on Github external
_searchWrapper(filter) {
      this.clearErrors();
      this.setProperties({
        mainCollection: [],
        "selectKit.isLoading": true,
        "selectKit.enterDisabled": true,
      });
      this._safeAfterRender(() => this.popper && this.popper.update());

      let content = [];

      return Promise.resolve(this.search(filter))
        .then((result) => {
          content = content.concat(makeArray(result));
          content = this.selectKit.modifyContent(content).filter(Boolean);

          if (this.selectKit.valueProperty) {
            content = content.uniqBy(this.selectKit.valueProperty);
          } else {
            content = content.uniq();
          }

          if (this.selectKit.options.limitMatches) {
            content = content.slice(0, this.selectKit.options.limitMatches);
          }

          const noneItem = this.selectKit.noneItem;
          if (