简体   繁体   中英

apply() does not work on Node.js eventemitter's emit() function

The apply() method does not work on Node's eventemitter's emit function.

I execute these 2 statements:

this._baseEmitter.emit('activity', {test: 'zever1'});

this._baseEmitter.emit.apply(this, ['activity', {test: 'zever2'}]);

The first 1 runs fine, and the event is captured by my listener.

The second one, however, does absolutely nothing.

Does anyone know why? Is the emit() function perhaps missing the apply method? If so, I would think I would receive some error messages, but that's not the case either.

第一个参数不应该是this._baseEmitter吗?

this._baseEmitter.emit.apply(this._baseEmitter, ['activity', {test: 'zever2'}]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM