How does Meteor's optimistic UI handle server rejections and errors on dependent operations?
If I do :
var item1Id = Items.insert({list: groceriesId, name: "Watercress"}); // op1
var item = Items.findOne({_id: item1Id});
Items.update(item, {$set: {name: "Peppers"}}); // op2
Items.insert({list: groceriesId, name: "Cheese"}); // op3
If op1
fails on the server-side but succeeds on the client-side, what will happen to op2
and op3
?
Will they both be rolled back?
If op1 fails then op2 will get rolled back (because it's an update to an object that doesn't exist). op3 will succeed assuming it doesn't also fail atomically.
If you wanted to prevent op3 from happening unless you were sure that op1 had succeeded then you could do it in a callback from op1.