Skip to content

Global singleton instance of Node.js EventEmitter. Helps modules communicate with each other.

License

Notifications You must be signed in to change notification settings

dvs-crcr/ts-global-emitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

global-emitter

NPM Version

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!");
});

License

MIT

About

Global singleton instance of Node.js EventEmitter. Helps modules communicate with each other.

Topics

Resources

License

Stars

Watchers

Forks