You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Backbone adheres to how REST API's work. REST does not generally support DELETE on ranges or lists. That's why the Collection class does not have a destroy method. You'll have to build custom support for that yourself, if you really need it. However don't expect Backbone to ever support that.
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.
If you use a decent promise library and some smart looping you can do all or some of these HTTP calls "concurrently" and you won't have to wait for each of them to finish before starting another. That will probably speed up your the deletion process tremendously.
Note that I'm not a backbone maintainer but a maintainer will probably say the same.
I'm a Backbone maintainer (although only since recently) and in principle, I agree with what @jaapz wrote, though I also wonder: do you really need to destroy those models if you just want to see fewer of them? Besides, the destroy method is already non-blocking.
There's probably something I'm misunderstanding about the question. @jwogan5 please clarify whenever it suits you, I'll save this on ice in the meanwhile.
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.
The text was updated successfully, but these errors were encountered: