我想知道如果给出的示例可以在真实服务器上满足竞争条件,是否可以在localhost上运行。给定情况 - 用户从表单中删除一些人(比如studyForm和studyPersons)我已经将personToDelete添加到一个数组中稍后 - 编辑操作我在循环中删除它们
// A punch of persons chosen to be deleted
self.markedForDeleted.forEach(function(trashed){
trashed.destroyRecord();
});
this.get('person').save().then(personEditSuccess, personEditFailure);
我应该像这样编辑吗?
var onDeleteSuccess = function(wasAnyToDelete){
if (wasAnyToDelete){
deletedPersons ++;
}
if(deletedPersons === lengthOfAllPersons) {
this.get('person').save().then(personEditSuccess, personEditFailure);
}
};
// A punch of persons chosen to be deleted
self.markedForDeleted.forEach(function(trashed){
trashed.destroyRecord().then(onDeleteSuccess, onDeleteFailure);
});
答案 0 :(得分:1)
正在使用
Ember.RSVP.all(personsToDelete.invoke('destroyRecord')).then(deletePersonSuccess, deletePersonFailure);