Methods for EventEmitter | Description |
---|---|
emitter.once(event, listner) | Used to add one time listener to event which is called only when the event get fired the next time and then after it get's removed. |
emitter.removeListener(event, listener) | In the specified event the listener array can be removed using this EventEmitter method. |
emitter.addListener(event, listener) | In the specified event the listener array can be added using this EventEmitter method. There is no way to check the already existing listener. |
emitter.removeAllListeners([event]) | This method is used to remove the specified events or removes all the events. |
emitter.on(event, listener) | In the specified event the listener array can be added using this EventEmitter method. There is no way to check the already existing listener and is similar to emitter.addListener() event. |
emitter.listeners(event) | By using the method, the specified events gets returned by a copy of listener array. |
emitter.setMaxListeners(n) | By using this method, if user add more than 10 listeners the EventEmitters will print a warning message by default. |
emitter.getMaxListeners() | By using this method, the EventEmitters current maximum listener value get return and this can be set either by default EventEmitter.defaultMaxListners or by emitter.setMaxListeners. |
emitter.emit(event[, arg1][, arg2][, ...]) | By using this method, the specified events can be raised with the supplied arguments. |
console.log()
will execute immediately after the Database.Query()
method. The below figure demonstrate the Asynchronous single and multi thread functions.
Synchronous :
This function executes the operation only by completing the previous operation i.e. The command console.log()
execute only when the query completed executing in order to obtain result from database. The below figure demonstrate the Synchronous single and multi thread functions.