
An event manager very simple
Compatibility
All browser | Backend (Nodejs) | Mobile (React Native) |
---|
✅ | ✅ | ✅ |
Compatibility with all javascript project
Install
npm install jetemit
Import
const { on, emit } = require("jetemit");
import { on, emit } from "jetemit";
Use
Call
import { emit } from "jetemit";
emit("TIME", "2018-12-01 12:30");
Listener
import { on } from "jetemit";
on("TIME", time => {
console.log(time);
});
import { once } from "jetemit";
once("TIME", time => {
console.log(time);
});
Unsubscribe listener
import { on } from "jetemit";
const unsubscribe = on("TIME", time => {
console.log(time);
});
unsubscribe();
Using unsubscribeOf function
import { unsubscribeOf } from "jetemit";
unsubscribeOf("TIME");
or
unsubscribeOf("TIME", timeFunction);
Refund from all listener
Please see this sample:
import { on } from "jetemit";
on("CACHE_STSTEM_HEALTH", () => {
return { state: "OK", id: "CACHE_SYSTEM_1" };
});
import { on } from "jetemit";
on("CACHE_STSTEM_HEALTH", () => {
return { state: "OK", id: "CACHE_SYSTEM_2" };
});
import { on, emit } from "jetemit";
const status = emit("CACHE_STSTEM_HEALTH");
console.log(status);
Donate
BTC: 1NV1sjQnXwuyHgxQ8G5eWprhxsD5A8yN6r