Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow for attaching events for initial rows in set #15

wants to merge 3 commits into


None yet
2 participants

Raynos commented Jan 16, 2013

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.


dominictarr commented Jan 16, 2013

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.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...

Raynos commented Jan 16, 2013

set.every works for me.


dominictarr commented Jan 16, 2013

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?


Raynos commented Jan 16, 2013

@dominictarr what about forAll


dominictarr commented Jan 16, 2013

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...


dominictarr commented Jan 17, 2013

@Raynos what do you think about onEach


Raynos commented Jan 17, 2013

onEach is fine

@Raynos Raynos referenced this pull request Jan 18, 2013


On each #18


Raynos commented Jan 18, 2013

See #18

@Raynos Raynos closed this Jan 18, 2013

@Raynos Raynos deleted the Raynos:set-events branch Jan 18, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment