base.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var tslib_1 = require("tslib");
  4. var event_emitter_1 = require("@antv/event-emitter");
  5. var util_1 = require("../util/util");
  6. var Base = /** @class */ (function (_super) {
  7. tslib_1.__extends(Base, _super);
  8. function Base(cfg) {
  9. var _this = _super.call(this) || this;
  10. /**
  11. * 是否被销毁
  12. * @type {boolean}
  13. */
  14. _this.destroyed = false;
  15. var defaultCfg = _this.getDefaultCfg();
  16. _this.cfg = util_1.mix(defaultCfg, cfg);
  17. return _this;
  18. }
  19. /**
  20. * @protected
  21. * 默认的配置项
  22. * @returns {object} 默认的配置项
  23. */
  24. Base.prototype.getDefaultCfg = function () {
  25. return {};
  26. };
  27. // 实现接口的方法
  28. Base.prototype.get = function (name) {
  29. return this.cfg[name];
  30. };
  31. // 实现接口的方法
  32. Base.prototype.set = function (name, value) {
  33. this.cfg[name] = value;
  34. };
  35. // 实现接口的方法
  36. Base.prototype.destroy = function () {
  37. this.cfg = {
  38. destroyed: true,
  39. };
  40. this.off();
  41. this.destroyed = true;
  42. };
  43. return Base;
  44. }(event_emitter_1.default));
  45. exports.default = Base;
  46. //# sourceMappingURL=base.js.map