storybook/dist/KnobStore.js
Arunoda Susiripala 2725deede2 Add dist.
2016-09-09 14:48:51 +05:30

68 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require("babel-runtime/helpers/createClass");
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var KnobStore = function () {
function KnobStore() {
(0, _classCallCheck3.default)(this, KnobStore);
this.store = {};
this.callbacks = [];
}
(0, _createClass3.default)(KnobStore, [{
key: "has",
value: function has(key) {
return this.store[key] !== undefined;
}
}, {
key: "set",
value: function set(key, value) {
this.store[key] = value;
this.callbacks.forEach(function (cb) {
return cb();
});
}
}, {
key: "get",
value: function get(key) {
return this.store[key];
}
}, {
key: "getAll",
value: function getAll() {
return this.store;
}
}, {
key: "reset",
value: function reset() {
this.store = {};
}
}, {
key: "subscribe",
value: function subscribe(cb) {
this.callbacks.push(cb);
}
}, {
key: "unsubscribe",
value: function unsubscribe(cb) {
var index = this.callbacks.indexOf(cb);
this.callbacks.splice(index, 1);
}
}]);
return KnobStore;
}();
exports.default = KnobStore;