Skip to content

How to create and use event emitter interface on Node.js add-ons

License

Notifications You must be signed in to change notification settings

abrindam/addon-event-emitter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event Emitter on Node.js Native Addons using N-API

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

Examples

Node.js C / C ++ Addons

N-API

Node Addon API

Header-only C++ wrapper classes for the ABI-stable Node.js API

Web resources

Nicola Del Gobbo

https://github.com/NickNaso/

https://www.npmjs.com/~nicknaso

https://twitter.com/NickNaso

Acknowledgements

Thank you to all people that encourage me every day.

License

Licensed under Apache license V2

About

How to create and use event emitter interface on Node.js add-ons

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 60.3%
  • JavaScript 25.0%
  • Python 14.7%