Log when a derived gets cleared (#236739)

pull/236759/head
Henning Dieterichs 2024-12-20 20:01:59 +01:00 committed by GitHub
parent 094e96a2ea
commit 83c336d7d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -220,6 +220,7 @@ export class Derived<T, TChangeSummary = any> extends BaseObservable<T, void> im
*/
this.state = DerivedState.initial;
this.value = undefined;
getLogger()?.handleDerivedCleared(this);
for (const d of this.dependencies) {
d.removeObserver(this);
}

View File

@ -48,6 +48,7 @@ export interface IObservableLogger {
handleDerivedCreated(observable: Derived<any>): void;
handleDerivedRecomputed(observable: Derived<any>, info: IChangeInformation): void;
handleDerivedCleared(observable: Derived<any>): void;
handleBeginTransaction(transaction: TransactionImpl): void;
handleEndTransaction(): void;
@ -170,6 +171,15 @@ export class ConsoleObservableLogger implements IObservableLogger {
changedObservables.clear();
}
handleDerivedCleared(derived: Derived<unknown>): void {
if (!this._isIncluded(derived)) { return; }
console.log(...this.textToConsoleArgs([
formatKind('derived cleared'),
styled(derived.debugName, { color: 'BlueViolet' }),
]));
}
handleFromEventObservableTriggered(observable: FromEventObservable<any, any>, info: IChangeInformation): void {
if (!this._isIncluded(observable)) { return; }