How do I create a promise in Ember.js for an Ember-data model

前端 未结 1 1560
梦毁少年i
梦毁少年i 2020-12-15 20:57

I have an Ember-Data model. I would like to do some processing in the .then promise once it has loaded and then return the same model as a promise. This is what I have right

相关标签:
1条回答
  • 2020-12-15 21:21

    Basically you can create a promise like this:

    var promise = new Ember.RSVP.Promise(function(resolve, reject){
      // succeed
      resolve(value);
      // or reject
      reject(error);
    });
    

    and then you can use the then property to chain it further:

    promise.then(function(value) {
      // success
    }, function(value) {
      // failure
    });
    

    You can aslo have a look at this jsbin which shows how they could be implemented. And this is also very helpful.

    Hope it helps.

    0 讨论(0)
提交回复
热议问题