mirror of
https://github.com/microsoft/vscode.git
synced 2026-10-02 05:51:37 +01:00
improves observable dev tools (#254942)
This commit is contained in:
@@ -24,9 +24,15 @@ export type ObsDebuggerApi = {
|
||||
getDerivedInfo(instanceId: ObsInstanceId): IDerivedObservableDetailedInfo;
|
||||
getAutorunInfo(instanceId: ObsInstanceId): IAutorunDetailedInfo;
|
||||
getObservableValueInfo(instanceId: ObsInstanceId): IObservableValueInfo;
|
||||
|
||||
setValue(instanceId: ObsInstanceId, jsonValue: unknown): void;
|
||||
getValue(instanceId: ObsInstanceId): unknown;
|
||||
|
||||
// For autorun and deriveds
|
||||
rerun(instanceId: ObsInstanceId): void;
|
||||
|
||||
logValue(instanceId: ObsInstanceId): void;
|
||||
|
||||
getTransactionState(): ITransactionState | undefined;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -135,7 +135,25 @@ export class DevToolsLogger implements IObservableLogger {
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
logValue: (instanceId) => {
|
||||
const obs = this._aliveInstances.get(instanceId);
|
||||
if (obs && 'get' in obs) {
|
||||
console.log('Logged Value:', obs.get());
|
||||
} else {
|
||||
throw new BugIndicatingError('Observable is not supported');
|
||||
}
|
||||
},
|
||||
rerun: (instanceId) => {
|
||||
const obs = this._aliveInstances.get(instanceId);
|
||||
if (obs instanceof Derived) {
|
||||
obs.debugRecompute();
|
||||
} else if (obs instanceof AutorunObserver) {
|
||||
obs.debugRerun();
|
||||
} else {
|
||||
throw new BugIndicatingError('Observable is not supported');
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -400,6 +400,14 @@ export class Derived<T, TChangeSummary = any, TChange = void> extends BaseObserv
|
||||
this._value = newValue as any;
|
||||
}
|
||||
|
||||
public debugRecompute(): void {
|
||||
if (!this._isComputing) {
|
||||
this._recompute();
|
||||
} else {
|
||||
this._state = DerivedState.stale;
|
||||
}
|
||||
}
|
||||
|
||||
public setValue(newValue: T, tx: ITransaction, change: TChange): void {
|
||||
this._value = newValue;
|
||||
const observers = this._observers;
|
||||
|
||||
Reference in New Issue
Block a user