jashkenas / jashkenas/backbone

Destroy All Models At Once

Open
#4,228 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
28.1k
Forks
5.3k
PR merge metrics
No merged PRs in 30d

Description

I know that backbone likes to call destroy on each model but in my particular case, it would be nice to be able to destroy all models in a collection with one call to speed up the process.

My scenario.
I am using Appcelerator which uses backbone collections to bind models to a list view. Say I have 100 models in the collection bound to the listview. This listview contains leads ( customers who made a call to a dealership in the past 30 days). Now I only want to show the customers who made calls to the dealer in the past 7 days. I could use reset but that does not remove the models so the current list would still show the 30-day list instead of the 7-day list. In order to show the 7-day list, I have to run a loop to destroy each model in the collection and re-populate the collection. The destroy loop for just 100 items takes about 10 seconds while adding the items takes under a second.

Without being able to remove all at once the UI since Appcelerator runs on the main thread is frozen until all the models are deleted. Currently, there is no workaround for this issue.

Contributor guide

Open the contributing guide

Research direction

The issue provides no file or test path; start by tracing Backbone collection and model destruction, along with the Appcelerator integration described. Done means a collection-level operation can remove all models without the current per-model destruction loop and avoids freezing the UI during the operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.