mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
don't throw when container is already disposed, just dispose immediately
This commit is contained in:
parent
068d25266c
commit
364295c7a9
@ -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 New Issue
Block a user