Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Created May 13, 2020 10:37
Show Gist options
  • Save mafintosh/882235c9a76efc09c7ba9af2d18fa29f to your computer and use it in GitHub Desktop.
Save mafintosh/882235c9a76efc09c7ba9af2d18fa29f to your computer and use it in GitHub Desktop.
const events = new require('events')
const { once } = events
const e = new events.EventEmitter()
main()
async function main () {
await once(e, 'foo')
console.log('foo was emitted')
await once(e, 'bar')
console.log('bar was emitted')
}
e.emit('foo')
e.emit('bar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment