search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Programming Dictionary

Online technical manual for service programmers
Popular searches:
Dictionary homepage JavaScript Node.js Node.js EventEmitter
Node.js EventEmitter Detailed instructions for use

Node.js EventEmitter

Chinese translation Recent Updates: 2018-06-21 10:23:30

Node.js is a platform built on the Chrome JavaScript runtime.

Node.js is an event-driven I/O server-side JavaScript environment based on Google's V8 engine. The V8 engine executes Javascript very quickly and has very good performance.

Node.js EventEmitter syntax

Node.js All asynchronous I/O operations will send an event to the event queue when completed.

Many objects in Node.js will emit events: a net.Server object will emit an event every time there is a new connection, and a fs.readStream object will emit an event when the file is opened. All of these event-generating objects are instances of events.EventEmitter.

Node.js EventEmitter example

//event.js file

var EventEmitter = require('events').EventEmitter; 
var event = new EventEmitter(); 
event.on('some_event', function() {     console.log('some_event 事件触发'); }); 
setTimeout(function() {     event.emit('some_event'); }, 1000);
Node.js EventEmitter