UNPKG

react-dnd

Version:
46 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Represents a disposable resource whose underlying disposable resource can * be replaced by another disposable resource, causing automatic disposal of * the previous underlying disposable resource. */ var SerialDisposable = /** @class */ (function () { function SerialDisposable() { this.isDisposed = false; } /** * Gets the underlying disposable. * @returns {Any} the underlying disposable. */ SerialDisposable.prototype.getDisposable = function () { return this.current; }; SerialDisposable.prototype.setDisposable = function (value) { var shouldDispose = this.isDisposed; if (!shouldDispose) { var old = this.current; this.current = value; if (old) { old.dispose(); } } if (shouldDispose && value) { value.dispose(); } }; /** Performs the task of cleaning up resources. */ SerialDisposable.prototype.dispose = function () { if (!this.isDisposed) { this.isDisposed = true; var old = this.current; this.current = undefined; if (old) { old.dispose(); } } }; return SerialDisposable; }()); exports.SerialDisposable = SerialDisposable; //# sourceMappingURL=SerialDisposable.js.map