don't throw when container is already disposed, just dispose immediately

This commit is contained in:
Bruno Windels 2021-02-22 10:47:17 +01:00
parent 068d25266c
commit 364295c7a9

View file

@ -32,12 +32,14 @@ export class Disposables {
}
track(disposable) {
if (this.isDisposed) {
throw new Error("Already disposed, check isDisposed after await if needed");
}
if (!isDisposable(disposable)) {
throw new Error("Not a disposable");
}
if (this.isDisposed) {
console.warn("Disposables already disposed, disposing new value");
disposeValue(disposable);
return disposable;
}
this._disposables.push(disposable);
return disposable;
}