Adds support for pwa-node and adds a poll option.

This commit is contained in:
Henning Dieterichs
2020-07-20 19:40:12 +02:00
parent e5707a0f2e
commit 5964c1c503
10 changed files with 162 additions and 77 deletions

View File

@@ -17,7 +17,7 @@ import {
import { getApi as getVsCodeApi } from "./VsCodeApi";
import { MonacoBridge } from "./MonacoBridge";
import { Disposable } from "@hediet/std/disposable";
import { startInterval } from "@hediet/std/timer";
import { startInterval, EventTimer } from "@hediet/std/timer";
declare const window: Window & {
webViewData?: {
@@ -55,6 +55,11 @@ export class Model {
| VisualizationId
| undefined = undefined;
@observable isPolling = false;
private readonly pollingTimer = this.dispose.track(
new EventTimer(500, "stopped")
);
@action
public setPreferredVisualizationId(id: VisualizationId) {
this.preferredVisualizationId = id;
@@ -65,6 +70,16 @@ export class Model {
this.state = { kind: "visualizationError", data: data };
}
@action
public setPolling(value: boolean) {
this.isPolling = value;
if (value) {
this.pollingTimer.start();
} else {
this.pollingTimer.stop();
}
}
@computed get visualizations():
| {
visualization: Visualization | undefined;
@@ -163,6 +178,10 @@ export class Model {
this.setExpression(state.expression);
}
});
this.pollingTimer.onTick.sub(() => {
this.refresh();
});
}
@action