-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a method for adding multiple items to the collection at once #7627
Comments
I'm wondering whether we should add also a complimentary While it is possible to keep similar interface similarity between The case with Few options that I see here are:
|
My 2¢:
The name is terrible for me. If not extending |
Yeah, I also like the way backbone handles this. But they have the first argument an array (iterable) by default and we cannot do this because this would mean a BC in 1000 different places. We have to support:
and this collides with the OTTH we cannot do |
We can't extend
The "batch" word is meant to underline that's an insertion of a bigger sequence into an already existing data strucutre. IMHO Not sure about the |
So, long story short, we need another method (which I personally hate). I also don't like this model batch connotation. Maybe
|
And JavaScript has
That being said, I can see the reason why we should avoid word "batch" in v5, so However in case of changing the name also the event name should changed. I could either go with
|
The |
If we were to simplify the
Also in this case the event should be further simplified, instead
Again, going this direction will mean that if we implement I'd opt for going #7627 (comment) so that we won't have this problem in the future. In the end, typically you just listen for |
Hmmm, what about not worrying about that - again looking at the Backbone data it could be: fire( 'change', {
added: [],
removed: [],
index: 0
} ); |
Might work, using a single index will handle potential Having that said it's high time to go with the implementation. |
📝 Provide a description of the new feature
When working on #6194 we figured that it would be good to have a way to add multiple items into a collection at once.
The tl;dr motivation is that when the colleciton changes, a resource-heavy logic needs to be run. Currently the only option is to listen to
add
event and run the logic for each added item - which is inefficient.Instead a
addBatch
method and event pair will solve this.Note that this new method needs to play well with existing
add
event. Also callingcollection.add()
should triggerbatchAdd
event too.If you'd like to see this feature implemented, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: