Package Exports
- my-custom-event-emitter
- my-custom-event-emitter/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (my-custom-event-emitter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Custom Event Emitter
A simple event emiiter utility to subscribe, emit and release events.
Installation
npm install my-custom-event-emitter
Usage
Example:
# import package
const Emitter = require("my-custom-event-emitter");
# initialise the constructor from imported package
const emitter = new Emitter();
# subscribe expects two arguments, one is event type and other is callback
emitter.subscribe('message', (args) => console.log(args));
# emit takes take multiple arguments where the first argument must with event type which you wan to emit
emitter.emit('message', 'arg1', 'arg2');
# release the event type by passing event type as argument to release method
emitter.release('message');