@protagonists/emitter
v1.1.2
Published
A simple emitter package
Downloads
7
Readme
About
A simple event handler package
Now works with
@protagonists/coerce
version 1.1.2!
Table of content
The content below may not correspond to the object structure of the objects
How to use?
Description
This package is used to listen and emit events to react to asynchronous events in a cleaner way
Import
Terminal
npm install @protagonists/emitter
Node.js
const Emitter = require("@protagonists/emitter");
Example
Code:
// Imports
const Emitter = require("@protagonists/emitter");
// Create Emitter instance
const myEmitter = new Emitter();
// Create one time event listener
myEmitter.once("ready", () => {
console.log("Ready event was sent!");
});
// Emit event
myEmitter.emit("ready");
Output:
Ready event was sent!