samedi 2 juin 2018

Convert Ember function to async await

I'd like to convert this Ember route action to use ES7 async / await. Can someone please explain what this would look like?

Per spec, I already added: babel: { includePolyfill: true } to my ember-cli-build.js file:

save() {
      let tenant = this.modelFor(this.routeName).tenant;
      let app = this.modelFor(this.routeName).app;

      return tenant.save().then(()=> {
        return tenant.get('app').save({ adapterOptions: { tenantId: tenant.id }}).then(() => {
          this.transitionTo('tenants.tenant.info', tenant.id);
        }).catch((error) => {
          tenant.get('app').rollback();
          throw error;
        });
      }).catch((error) => {
        tenant.rollback();
        throw error;
      });
    }




Aucun commentaire:

Enregistrer un commentaire