How to use the rsvp.Promise 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 HospitalRun / hospitalrun-frontend / app / services / filesystem.js View on Github external
fileExists(filePath) {
    return new EmberPromise(function(resolve) {
      let filer = this.get('filer');
      filer.fs.root.getFile(filePath, {}, function() {
        resolve(true);
      }, function() {
        // if ls errs, file doesn't exist.
        resolve(false);
      });
    }.bind(this));
  },
github Flexberry / ember-flexberry-designer / addon / utils / fd-preload-stage-metadata.js View on Github external
export default function fdPreloadStageMetadata(store, stagePk) {
  return new Promise(function(resolve, reject) {
    let promises = [];

    const projectionName = 'FdPreloadMetadata';

    // stage promise
    let modelName = 'fd-dev-stage';
    let q = new Builder(store, modelName)
      .selectByProjection(projectionName)
      .byId(stagePk)
      .build();
    promises.push(store.query(modelName, q));

    // classes promise
    promises.push(getPromise(store, stagePk, 'fd-dev-class', projectionName));

    // associations promise
github machty / ember-navigator / tests / dummy / app / routes / x-user.js View on Github external
load({ user_id }) {
    let signInThing = this.signInThing;
    let user = { id: user_id, name: 'alex' };
    return new Promise(r => {
      setTimeout(() => {
        r({
          user,
          fun: Math.floor(300 * Math.random()),
        })
      }, 800);
    });
  }
}
github shipshapecode / ember-cli-release / tests / fixtures / project-with-strategy-config / config / release.js View on Github external
function writeFile(rootPath, filePath, contents) {
  return new RSVP.Promise(function(resolve) {
    fs.writeFile(path.join(rootPath, filePath), contents, resolve);
  });
}
github HospitalRun / hospitalrun-frontend / app / medication / edit / controller.js View on Github external
beforeUpdate() {
    let isFulfilling = this.get('isFulfilling');
    let isNew = this.get('model.isNew');
    if (isNew || isFulfilling) {
      return new EmberPromise(function(resolve, reject) {
        let newMedication = this.get('model');
        newMedication.validate().then(function() {
          if (newMedication.get('isValid')) {
            if (isNew) {
              if (isEmpty(newMedication.get('patient'))) {
                this.addNewPatient();
                reject({
                  ignore: true,
                  message: 'creating new patient first'
                });
              } else {
                newMedication.set('medicationTitle', newMedication.get('inventoryItem.name'));
                newMedication.set('priceOfMedication', newMedication.get('inventoryItem.price'));
                newMedication.set('status', 'Requested');
                newMedication.set('requestedBy', newMedication.getUserName());
                newMedication.set('requestedDate', new Date());
github Azure / azure-arm-validator / routes / validate.js View on Github external
router.post('/validate', function (req, res) {

  var fileName = tempDir + '/' + Guid.raw(),
    parametersFileName = tempDir + '/' + Guid.raw(),
    promise = new RSVP.Promise((resolve) => {
      resolve();
    }),
    preReqFileName,
    preReqParametersFileName;

  replaceSpecialParameterPlaceholders(req);

  debug('pull request number: ' + req.body.pull_request);
  if (req.body.pull_request) {
    promise = promise
      .then(() => {
        return replaceRawLinksForPR(req.body.template, req.body.pull_request);
      })
      .then((modifiedTemplate) => {
        debug('modified template is:');
        debug(modifiedTemplate);
github Orbs / jspm-git / git.js View on Github external
function checkMain(main, libDir) {
      if (!main) {
        return Promise.resolve(false);
      }

      if (main.substr(main.length - 3, 3) === '.js') {
        main = main.substr(0, main.length - 3);
      }

      return new Promise(function(resolve) {
        fs.exists(path.resolve(dir, libDir || '.', main) + '.js', function(exists) {
          resolve(exists);
        });
      });
    }
github peec / ember-css-transitions / addon / mixins / transition-mixin.js View on Github external
export function nextTick() {
  return new RSVP.Promise((resolve) => {
    schedule('afterRender', () => {
      rAF(() => {
        resolve();
      });
    });
  });
}
github Flexberry / ember-flexberry-designer / addon / controllers / fd-all-projects / new.js View on Github external
project: project,
          id: uuid.v4()
        });

        updateData.pushObject(configuration);
      }

      let stage = store.createRecord('fd-dev-stage', {
        name: this.get('projectName'),
        description: this.get('projectDescription'),
        configuration: configuration,
      });

      this.get('appState').loading();

      new Promise(function(resolve) {
        if (updateData.length > 0) {
          resolve(store.batchUpdate(updateData));
        } else {
          resolve();
        }
      })
      .then(() => stage.save())
      .then(() => {
        currentProjectContext.setCurrentConfiguration(configuration);
        currentProjectContext.setCurrentStage(stage);

        return FdPreloadStageMetadata.call(this, store, currentProjectContext.getCurrentStage());
      })
      .then(() => currentProjectContext.getAutogeneratedSystemPromise())
      .then(() => {
        this.get('appState').reset();
github ghostery / ghostery-extension / app / panel / components / CreateAccount.jsx View on Github external
this.props.actions.register(email, confirmEmail, firstName, lastName, password).then((success) => {
						this.setState({ loading: false });
						if (success) {
							this.props.actions.updateAccountPromotions(promotionsChecked);
							new RSVP.Promise((resolve) => {
								this.props.actions.getUser()
									.then(() => resolve())
									.catch(() => resolve());
							}).finally(() => {
								this.props.history.push('/account-success');
							});
						}
					});
				});