collection
collection copied to clipboard
added add/remove methods with emitting
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.
Any chance to get this merged?
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
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]
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
i think i made a few minor modifications, but the only big change is arr.at(i) => arr[i]