It\'s there a way to configure the setInterval
method of javascript to execute the method immediately and then executes with the timer
For someone needs to bring the outer this
inside as if it's an arrow function.
(function f() {
this.emit("...");
setTimeout(f.bind(this), 1000);
}).bind(this)();
If the above producing garbage bothers you, you can make a closure instead.
(that => {
(function f() {
that.emit("...");
setTimeout(f, 1000);
})();
})(this);
Or maybe consider using the @autobind decorator depending on your code.