Currently, both timers and nextTick only take a callback argument (and some timers take a duration argument).
It is beneficial to pass additional arguments and/or the context to timers. The io.js code base is littered with code like:
varself=this;process.nextTick(function(){self.emit('close');});It's possible to either pass a context (this) to these functions or to pass arguments like the DOM version does making the above:
process.nextTick(function(){this.emit('close');},this);Or:
process.nextTick(function(element){element.emit('close');},this);This can make cleaner code and save closure allocations - it also isn't slow like .bind.
Was this proposed before?
I realize the Timers API is locked (nextTick is not afaict) but I'm wondering how people feel about this.
Currently, both timers and
nextTickonly take a callback argument (and some timers take a duration argument).It is beneficial to pass additional arguments and/or the context to timers. The io.js code base is littered with code like:
It's possible to either pass a context (
this) to these functions or to pass arguments like the DOM version does making the above:Or:
This can make cleaner code and save closure allocations - it also isn't slow like
.bind.Was this proposed before?
I realize the Timers API is locked (
nextTickis not afaict) but I'm wondering how people feel about this.