UNPKG

react-elegant-ui

Version:

Elegant UI components, made by BEM best practices for react

27 lines (26 loc) 668 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SimpleEventChannel = void 0; /** * Simple event channel to send and handle messages */ var SimpleEventChannel = exports.SimpleEventChannel = /** @class */function () { function SimpleEventChannel() { var _this = this; this.handlers = new Set(); this.subscribe = function (fn) { _this.handlers.add(fn); }; this.unsubscribe = function (fn) { _this.handlers.delete(fn); }; this.send = function (value) { _this.handlers.forEach(function (handler) { return handler(value); }); }; } return SimpleEventChannel; }();