Closed Raynos closed 11 years ago
hmm, I think it's better to iterate over the set... using next tick leaks implementation details...
when I have this problem I just go
function add (...) {...}
set.forEach(add)
set.on('add', add)
I think a better approach would be to add a function every
set.every(function(item) {
//this function is called first with all the current items,
//and THEN when ever an update comes in...
})
set.every works for me.
on second thoughts, every
isn't the best name, because that is already on the Array.prototype
.
what about set.onEach(function (item) {...}) I think that implys events, and forEach
... at least it doesn't collide with an existing api.
can you make a fresh pull request for this?
@dominictarr what about forAll
I don't feel that forAll
suggests anything about the temporal nature of this method, because for
is associated with ordinary iteration.
forAll
all sounds like a synonym for forEach
or is called once with an array of all the items...
@Raynos what do you think about onEach
onEach
is fine
See #18
Add existing rows to the set later.
This ensures the user has enough time to bind events to
"add"
and"changes"
on the set before those rows are added.The tradeoff is that you can't synchronously check
set.toJSON()
for any valid rows until the next tick.