UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

43 lines (42 loc) 1.31 kB
/** * DevExtreme (esm/viz/vector_map/data_exchanger.js) * Version: 21.1.4 * Build date: Mon Jun 21 2021 * * Copyright (c) 2012 - 2021 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import Callbacks from "../../core/utils/callbacks"; export function DataExchanger() { this._store = {} } DataExchanger.prototype = { constructor: DataExchanger, dispose: function() { this._store = null; return this }, _get: function(category, name) { var store = this._store[category] || (this._store[category] = {}); return store[name] || (store[name] = { callbacks: Callbacks() }) }, set: function(category, name, data) { var item = this._get(category, name); item.data = data; item.callbacks.fire(data); return this }, bind: function(category, name, callback) { var item = this._get(category, name); item.callbacks.add(callback); item.data && callback(item.data); return this }, unbind: function(category, name, callback) { var item = this._get(category, name); item.callbacks.remove(callback); return this } };