WBE_Praktikum_5/code/async/emitter.js

18 lines
292 B
JavaScript
Raw Permalink Normal View History

2022-10-27 08:21:03 +02:00
//
// Example using EventEmitter
//
const EventEmitter = require('events')
const door = new EventEmitter()
door.on('open', (arg) => {
console.log('Door was opened ' + arg)
})
process.nextTick(() => {
console.log('next tick')
door.emit('open', 'async')
})
door.emit('open', 'sync')