Node.js EventEmitter
Translation results:
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 EventEmittersyntax
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 EventEmitterexample
//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);
Popular Recommendations
- Getting started with RabbitMq using NodeJs
- Creating a ReAct Agent from the scratch with nodeJS ( wikipedia search )
- Event Handling in React
- Implementing Event-Driven Architectures in PHP: A Deep Dive into Event Sourcing and CQRS
- Similar Event De-duplication per Period
- Understanding the JavaScript Event Loop: A Beginner's Guide