UNPKG

@lumino/disposable

Version:
2 lines 1.56 kB
!function(s,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@lumino/signaling")):"function"==typeof define&&define.amd?define(["exports","@lumino/signaling"],e):e((s="undefined"!=typeof globalThis?globalThis:s||self).lumino_disposable={},s.lumino_signaling)}(this,(function(s,e){"use strict";class i{constructor(s){this._fn=s}get isDisposed(){return!this._fn}dispose(){if(!this._fn)return;let s=this._fn;this._fn=null,s()}}class t{constructor(){this._isDisposed=!1,this._items=new Set}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._items.forEach((s=>{s.dispose()})),this._items.clear())}contains(s){return this._items.has(s)}add(s){this._items.add(s)}remove(s){this._items.delete(s)}clear(){this._items.clear()}}!function(s){s.from=function(e){let i=new s;for(const s of e)i.add(s);return i}}(t||(t={}));class o extends t{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}!function(s){s.from=function(e){let i=new s;for(const s of e)i.add(s);return i}}(o||(o={})),s.DisposableDelegate=i,s.DisposableSet=t,s.ObservableDisposableDelegate=class extends i{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}},s.ObservableDisposableSet=o})); //# sourceMappingURL=index.min.js.map