40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
|
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var noop = function noop() {};
|
|
|
|
/**
|
|
* The basic disposable.
|
|
*/
|
|
|
|
var Disposable = (function () {
|
|
_createClass(Disposable, null, [{
|
|
key: "empty",
|
|
value: { dispose: noop },
|
|
enumerable: true
|
|
}]);
|
|
|
|
function Disposable(action) {
|
|
_classCallCheck(this, Disposable);
|
|
|
|
this.isDisposed = false;
|
|
this.action = action || noop;
|
|
}
|
|
|
|
Disposable.prototype.dispose = function dispose() {
|
|
if (!this.isDisposed) {
|
|
this.action.call(null);
|
|
this.isDisposed = true;
|
|
}
|
|
};
|
|
|
|
return Disposable;
|
|
})();
|
|
|
|
exports["default"] = Disposable;
|
|
module.exports = exports["default"]; |