Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs emit event from class

const EventEmitter = require('events');
module.exports = class animal extends EventEmitter {
    constructor(){
      super();
    }
    sound(){
      this.emit('sound', `miau`);
    }
}
 
PREVIOUS NEXT
Tagged: #nodejs #emit #event #class
ADD COMMENT
Topic
Name
5+2 =