-
-
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
Support adding 2+ items at once to Collection and FocusTracker #4992
Comments
Am I also correct in assuming that Collection cant be instantiated with an array? I wish to take a pre-existing array and move it into a collection. The only way I seem to be able to achieve this is const messages = ['One','Two','Three'];
// Incorrect
const collection = new Collection(messages);
// Correct?
const collection = new Collection();
messages.forEach(m => collection.add(m)); This enhancement would help with the above issue, allowing me to remove the forEach, but its strange I cant pass the array to the constructor. |
I agree this should be the right way to do it. @mlewand? |
Allowing for value members initialization thorough the constructor sounds like a nice addition. In this case It might be tempting to just allow How about adding a this.children.push( this.actionView, this.actionView ); And if one wants to append an array at a runtime, then it could be used like: this.children.push( ...[ this.actionView, this.actionView ] ); |
A good catch! OTOH, I ran all the editor tests and checked if we use Anyway, we could allow TL;DR, I propose two changes to the API: new Collection( Array, [ options] );
collection.add( itemA, itemB, itemC, ..., index ); cc @jodator |
Yeah, since we have |
Just to confirm because this is your proposal, options would be housed in an array? |
I get that as an optional parameter (as one would read this in the docs): Also other parts of the code use object for |
Ah! Apologies. I had taken new Collection( Array, [ options] );
collection.add( itemA, itemB, itemC, ..., index ); literally. I didn't realize in this context the braces were indicating Thank you |
Code from the split button view:
cc @oleq
The text was updated successfully, but these errors were encountered: