Lets say we have a function called doSomething();
Inside this function I am declaring an object called dispatcher.
dispatcher has a function that works asynchronously and omits an 'end' event when its finished.
So the code looks like this:
const doSomething = () => {
const dispatcher = someObject.function.thatReturnsDispatcher();
}
So this doSomething() function is not totally useless and actually does so much more than just assigning a single variable and I want this dispatcher to do the same stuff that doSomething()
does whenever its asynchronous function ends. So I do something like this:
const doSomething = async () => {
//important stuff above
const dispatcher = someObject.function.thatReturnsDispatcher();
dispatcher.on('end' , () => {
doSomething();
});
//important stuff below
}
and it works!
But I wonder one thing:
When it is called, does the function doSomething() works recursively or does the function end and node saves the discpatcher.on('end') function and calls it whenever an end event omits?