Last active
May 10, 2022 13:49
-
-
Save jonathasborges1/ac98f0262d5b5b46ee2c98d6c060bdf6 to your computer and use it in GitHub Desktop.
[NODE] - Questão de Prova - Analista de Tecnologia da Informação da Fazenda Estadual - SEFAZ - 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { EventEmitter } = require('events'); | |
class MyEmitter extends EventEmitter {} | |
const myEmitter = new MyEmitter(); | |
const callbackA = () => { | |
process.stdout.write('A'); | |
myEmitter.removeListener('event',callbackB); | |
}; | |
const callbackB = () => { | |
process.stdout.write('B'); | |
}; | |
myEmitter.on('event',callbackA); | |
myEmitter.on('event',callbackB); | |
for (x=0;x<=2;x++){ | |
myEmitter.emit('event'); | |
} | |
// Saida experada -> ABAA | |
// https://replit.com/languages/nodejs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment