Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs emit event from class

const EventEmitter = require('events');
module.exports = class animal extends EventEmitter {
    constructor(){
      super();
    }
    sound(){
      this.emit('sound', `miau`);
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to icon font-awesome react cart 
Javascript :: npm error Could not resolve dependency peer react@"^18.0.0" from react-test-renderer@18.0.0 
Javascript :: settimeout function es6 
Javascript :: get the last day of the month in js 
Javascript :: js function string parameter 
Javascript :: create javascript array 
Javascript :: find from string in javascript 
Javascript :: while vs do while javascript 
Javascript :: vue js default props 
Javascript :: js regex replace multiple matches 
Javascript :: add parameter to serialize javascript 
Javascript :: how to get folder names with fs 
Javascript :: node js kill process 
Javascript :: how to get the computer date and time jquery 
Javascript :: json.stringify vs json.parse 
Javascript :: image preview 
Javascript :: js count element tags 
Javascript :: javascript keyup event enter key 
Javascript :: array js fill 
Javascript :: antd dropdown stop propogation 
Javascript :: require a json as a string 
Javascript :: fuse.js npm 
Javascript :: javascript remove array element 
Javascript :: Capitalize the first letter of string using JavaScript 
Javascript :: jquery select first matching element 
Javascript :: export default method vue 
Javascript :: javascript add data to form 
Javascript :: jquery parent 
Javascript :: connect mysql to node js 
Javascript :: add checkbox dynamically in javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =