Bulk actions: destroy/update on multiple items


#1

How do you handle a bulk save or destroy?

I have something like this: let todos = TodoModel.getList() and every todo has a checkbox and are stored in a selection DefineList.
Now I want to delete the selected todo items.

selection.forEach(todo => {
  todo.destroy();
});

This results in multiple requests to the backend, how can I group these request?
Do I make a custom function in my model bulkDestroy and then splice them out of my todos list? Or how do you handle this?

@justinbmeyer suggested this on the gitter channel:

I would put a destroyList or some method on your list that makes the requests
and then call destroyedInstance on each one (assuming can-connect)

I have tried that but couldn’t make it work. The items are updated when calling Item.Connection.destroyedInstance(item, {title: 'destroyed'});. The title changes to destroyed, but I expected them to get removed from the list.

See this fiddle: