我将如何在实现单例设计模式的模块上继承 events.EventEmitter 方法?
var EventEmitter = require('events').EventEmitter;
var Singleton = {};
util.inherits(Singleton, EventEmitter);
Singleton.createClient = function(options) {
this.url = options.url || null;
if(this.url === null) {
this.emit('error', 'Invalid url');
} else {
this.emit('created', true);
}
}
module.exports = Singleton;
这会导致错误:TypeError: Object #<Object> has no method 'emit'