H
H
Hazrat Hajikerimov2017-04-14 12:45:01
Node.js
Hazrat Hajikerimov, 2017-04-14 12:45:01

Promises for EventEmmiter or callbacks?

// Какое-то событие
event.on('account:list', (user, account) => { 
   // Вызываем другое событие
   event.emit('account:empty', msg)
});

// Вызываем событие
event.emit('account:list', msg)

console.log('done')

for example, console.log('dene'), should be output after the above event is processed, including the inner event
. Is there any async/await solution for EventEmmiter or callbacks?
for example this:
event.emit('account:list', msg).then(() => {
console.log('done')
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2017-04-14
@SPAHI4

If the event is called many times. For example, a user request, then we use events.
If you need to wait for some action, for example, reading a file, then use Promise or async

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question