FiguredLimited / vue-mc

Models and Collections for Vue
https://vuemc.io
MIT License
627 stars 98 forks source link

Model's onDeleteSuccess behaviour makes it difficult to know what was deleted/removed #161

Open longhotsummer opened 3 years ago

longhotsummer commented 3 years ago

Model's onDeleteSuccess calls this.clear() before calling this.removeFromAllCollections and this.emit('delete'). This means that remove event handlers for associated collections, and delete event handlers on the model, don't have access to the details of the model that has been deleted.

This makes code like the following impossible:

collection.on('remove', e => {
  if (e.model.important_attribute) {
    // an important model was deleted
  }
});

Would it make sense to instead call clear() after the final emit()?