I am trying to understand this snippet of Node.js code.
Roee.js
const emitters = require('events');
module.exports=class Roee extends emitters{
constructor(eee){
super();
const emit = this.emit.bind(this);
this.emit=undefined;
eee(emit);
}
};
ticker.js
const emiCl = require('./roee');
const tikee = new emiCl((emiff) => {
let tickcnt=0;
setInterval(() => {
emiff('ticker',tickcnt++)
}, 1200);
}
);
module.exports = tikee;
tester.js
const mytickel = require('./tiker');
mytickel.on('ticker', (tickcount) => console.log(tickcount,'tempdfg'));
My questions:
Roee.js: The constructor takes an arg which is used as a function.
ticker.js: defines the function which is passed in roee.js. This function takes a parameter, which is again a function, right?
tester.js: how is this able to access the counter and pass argument to the function emiff('ticker',tickcnt++)?
I am at beginner stage.