forked from mystiq/hydrogen-web
don't throw when container is already disposed, just dispose immediately
This commit is contained in:
parent
068d25266c
commit
364295c7a9
1 changed files with 5 additions and 3 deletions
|
@ -32,12 +32,14 @@ export class Disposables {
|
||||||
}
|
}
|
||||||
|
|
||||||
track(disposable) {
|
track(disposable) {
|
||||||
if (this.isDisposed) {
|
|
||||||
throw new Error("Already disposed, check isDisposed after await if needed");
|
|
||||||
}
|
|
||||||
if (!isDisposable(disposable)) {
|
if (!isDisposable(disposable)) {
|
||||||
throw new Error("Not a 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);
|
this._disposables.push(disposable);
|
||||||
return disposable;
|
return disposable;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue