Add evaluateForEffect method to support expression evaluation for side effects
This commit is contained in:
@@ -161,6 +161,24 @@ export class Model {
|
||||
this.pollingTimer.onTick.sub(() => {
|
||||
this.refresh();
|
||||
});
|
||||
|
||||
// Exposed globally (not passed into custom visualizer scripts'
|
||||
// closures) for the same reason setVisualizationModule is below:
|
||||
// setCustomVisualizerScript's `eval()` runs plugin code in this
|
||||
// same window/global scope, so a plugin (see vis-plugins/node-
|
||||
// table-visualizer.js) can reach these to support editing values
|
||||
// in place, without threading a new parameter through the whole
|
||||
// register()/getVisualization()/render() plugin contract.
|
||||
(globalThis as any).debugVisualizerSetValue = (expression: string) =>
|
||||
this.evaluateForEffect(expression);
|
||||
(globalThis as any).debugVisualizerRefresh = () => this.refresh();
|
||||
}
|
||||
|
||||
async evaluateForEffect(expression: string): Promise<{ success: boolean; message: string }> {
|
||||
if (!this.server) {
|
||||
return { success: false, message: "Not connected to the debug visualizer server." };
|
||||
}
|
||||
return this.server.evaluateForEffect({ expression });
|
||||
}
|
||||
|
||||
@action
|
||||
|
||||
Reference in New Issue
Block a user