不要怂,就是干,撸起袖子干!

Commit f54644e6 by Mick Hansen

Why use self when we have bind?

1 parent fe77d52d
Showing with 2 additions and 5 deletions
...@@ -4,16 +4,13 @@ var util = require("util") ...@@ -4,16 +4,13 @@ var util = require("util")
module.exports = (function() { module.exports = (function() {
var CustomEventEmitter = function(fct) { var CustomEventEmitter = function(fct) {
this.fct = fct this.fct = fct
var self = this
} }
util.inherits(CustomEventEmitter, EventEmitter) util.inherits(CustomEventEmitter, EventEmitter)
CustomEventEmitter.prototype.run = function() { CustomEventEmitter.prototype.run = function() {
var self = this
process.nextTick(function() { process.nextTick(function() {
if (self.fct) { if (this.fct) {
self.fct.call(self, self) this.fct.call(this, this)
} }
}.bind(this)) }.bind(this))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!