make disposeTracked suitable to reassign member

This commit is contained in:
Bruno Windels 2020-05-05 23:19:02 +02:00
parent d0f09c5334
commit 54502c906f

View File

@ -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;
} }
} }