collection icon indicating copy to clipboard operation
collection copied to clipboard

added add/remove methods with emitting

Open ianstormtaylor opened this issue 12 years ago • 5 comments

a remove makes a lot of sense to me, in which case having the add alias is nicer imo. with push left for backwards compat.

and then i'd like to be able to listen to models being added/removed from collections.

ianstormtaylor avatar Jun 03 '13 04:06 ianstormtaylor

Any chance to get this merged?

esundahl avatar Jun 14 '13 01:06 esundahl

there's https://github.com/component/collection/pull/1/files as well, need to look at this stuff again, this lib has been stagnating for a while :D

tj avatar Jun 29 '13 00:06 tj

maybe take a look at https://github.com/matthewmueller/array. It was inspired by this lib / enumerable.

Has events and only difference between collection and array.js is that collection wraps array, while array.js uses array-like object (marginally slower, but more elegant api). ie:

// component/collection
var users = Collection([user1, user2])
var user = users.at(0)

// array.js
var users = array([user1, user2])
user = users[0]

matthewmueller avatar Jun 29 '13 03:06 matthewmueller

im down with replacing this module with "array", but it would be nice if we could get whatever changes were necessary in https://github.com/MatthewMueller/array/blob/master/lib/enumerable.js back into component/enumerable

tj avatar Jul 01 '13 20:07 tj

i think i made a few minor modifications, but the only big change is arr.at(i) => arr[i]

matthewmueller avatar Jul 01 '13 21:07 matthewmueller