jeudi 23 avril 2015

RSVP.all is not firing failure callback on ember-data save failure

I am wrapping a collection of saves in a Ember.RSVP.all aggregator promise and the failure callback is not firing when an individual failure triggers. I have also tried Ember.RSVP.allSettled.

I am using ember-data's active model adapter plugin and my backend is returning 422 Not Processable which should trigger the failure callback.

var blueprintSavePromises = blueprints.map(function(bp){
  return bp.save().then(function(){
    console.log("individual save was successful");
  }, function(){
    console.log("individual save failed");
  });
});

var allBlueprintPromises = Ember.RSVP.allSettled(blueprintSavePromises);
allBlueprintPromises.then(function(){
  console.log("collection was successful");
}).catch(function(){
  console.log("collection was not successful");
});


// PUT http://test/test 422 (Unprocessable Entity)
// jquery.js:9659 XHR finished loading: PUT ...
// test-file.js:94 individual save failed
// test-file.js:110 collection was successful

What am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire