UNPKG

@iore8655/react-bus

Version:

@iore8655/react-bus is a global/local state management by pub/sub

21 lines (20 loc) 582 B
"use strict"; exports.__esModule = true; exports.Bus = exports.context = void 0; exports.context = { subId: 0 }; var Bus = /** @class */ (function () { function Bus() { this.subscribers = {}; } Bus.prototype.getSubscribers = function () { return this.subscribers; }; Bus.prototype.subscribe = function (subId, callback) { this.subscribers[subId] = { callback: callback }; }; Bus.prototype.unsubscribe = function (subId) { delete this.subscribers[subId]; }; return Bus; }()); exports.Bus = Bus;