How to create and use Event Emitter on Node.js Native Addons
Node.js includes an event system which is an implementation of the Observer pattern that is the most common used event pattern in Node.js application and for good reasons: it's incredibly simple and useful.
Anyone who has used Node.js should be familiar with events. This module has the responsability to facilitate the communication between objects of your application.
Much of the Node.js core API modules are built aroud an idiomatic asynchronous event-driven architecture in which certains kinds of objects (called emitter) periodically emit named events that cause Function objects ("listeners") to be called.
Sometimes you need to promote loose coupling system by ensuring that instead of components (modules) referring to each other explicitly, their interaction is handled through an exchange of message using the events. This can help to decouple the systems and improve the module reusability.
Here you can find a collection of examples where I used or implemented event emitter interface in a Node.js Native AddOns.
In each example directory, run:
$ npm install
$ node-gyp rebuild
$ node index.js or npm start
- How I ported bcrypt to new N-API
- N-API the next API for Native Addons
- N-API Next generation Node API for native modules
- Speed up Your Node.js App with Native Addons
- Start with N-API
- How to get a performance boost using Node.js native addons
https://github.com/NickNaso/
https://www.npmjs.com/~nicknaso
Thank you to all people that encourage me every day.
Licensed under Apache license V2