Apply () not working in Node.js function eventemitter emit ()

The apply () method does not work in the Node eventemitter function emit

.

I am fulfilling these 2 statements:

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

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

      

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

The second, however, does nothing.

Does anyone know why? Perhaps the emit () function is missing an apply method? If so, I think I will get some error messages, but that is not the case either.

+3


source to share


1 answer


Shouldn't the first parameter be this._baseEmitter instead?



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

      

+16


source







All Articles