@crcr/global-emitter
v1.0.5
Published
Global singleton instance of Node.js EventEmitter. Helps modules communicate with each other.
Downloads
1
Maintainers
Readme
global-emitter
Global singleton instance of Node.js EventEmitter (module). Helps modules communicate with each other.
Install
$ npm i @crcr/global-emitter
Usage
Import
global-emitter
in every module where you want to emit event with another module.
// moduleOne.js
import { default as GlobalEmitter } from "@crcr/global-emitter";
// OR const GlobalEmitter = require("@crcr/global-emitter").default;
GlobalEmitter.emit("globalEvent");
// moduleTwo.js
import { default as GlobalEmitter } from "@crcr/global-emitter";
// OR const GlobalEmitter = require("@crcr/global-emitter").default;
GlobalEmitter.on("globalEvent", () => {
console.log("globalEvent successfully emitted!");
});