UNPKG

@appbuckets/react-ui-core

Version:

Core utilities built for AppBuckets React UI Framework

43 lines (40 loc) 1.05 kB
'use strict'; var NodeRegistry = /** @class */ (function () { function NodeRegistry() { var _this = this; this.nodes = new Map(); this.add = function (node, component) { // If nodes exists, add the component if (_this.nodes.has(node)) { var set = _this.nodes.get(node); if (set) { set.add(component); } return; } // Create the new Set using component _this.nodes.set(node, new Set([component])); }; this.remove = function (node, component) { // If node doesn't exists, return if (!_this.nodes.has(node)) { return; } var set = _this.nodes.get(node); if (!set) { return; } // If component is last, remove the node if (set.size === 1) { _this.nodes.delete(node); return; } set.delete(component); }; this.emit = function (node, callback) { callback(node, _this.nodes.get(node)); }; } return NodeRegistry; })(); module.exports = NodeRegistry;