What exactly is the difference between event listeners marked with the OnEvent decorators that use async: true
and the ones without it? Also what does promisify: true
do? I couldn't find it on the Nestjs Events docs page. Thank you
Those options aren't from Nest, but from eventemitter2
. Directly from their docs:
async:boolean= false
- invoke the listener in async mode using setImmediate (fallback to setTimeout if not available) or process.nextTick depending on the nextTick option.
nextTick:boolean= false
- use process.nextTick instead of setImmediate to invoke the listener asynchronously.
promisify:boolean= false
- additionally wraps the listener to a Promise for later invocation using emitAsync method. This option will be activated by default if its value is undefined and the listener function is an asynchronous function (whose constructor name is
objectify:boolean= false
- activates returning a listener object instead of 'this' by the subscription method.