base.js 1.1 KB

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