forked from mystiq/hydrogen-web
make disposeTracked suitable to reassign member
This commit is contained in:
parent
d0f09c5334
commit
54502c906f
1 changed files with 6 additions and 2 deletions
|
@ -25,12 +25,16 @@ export class Disposables {
|
||||||
}
|
}
|
||||||
|
|
||||||
disposeTracked(value) {
|
disposeTracked(value) {
|
||||||
|
if (value === undefined || value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const idx = this._disposables.indexOf(value);
|
const idx = this._disposables.indexOf(value);
|
||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
const [foundValue] = this._disposables.splice(idx, 1);
|
const [foundValue] = this._disposables.splice(idx, 1);
|
||||||
disposeValue(foundValue);
|
disposeValue(foundValue);
|
||||||
return true;
|
} else {
|
||||||
|
console.warn("disposable not found, did it leak?", value);
|
||||||
}
|
}
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue