diff src/index.ts @ 93:955cde1550c3

start the View work: parse view document
author drewp@bigasterisk.com
date Wed, 12 Jan 2022 20:26:57 -0800
parents 6ec759f9009f
children 2468f2227d22
line wrap: on
line diff
--- a/src/index.ts	Wed Jan 12 16:53:44 2022 -0800
+++ b/src/index.ts	Wed Jan 12 20:26:57 2022 -0800
@@ -18,7 +18,8 @@
 export class StreamedGraph extends LitElement {
   @property({ type: String })
   url: string = "";
-
+  @property({ type: String })
+  view: string = "";
   @property({ type: Object })
   graph!: VersionedGraph;
 
@@ -70,7 +71,8 @@
 
   redrawGraph() {
     this.graphViewDirty = true;
-    requestAnimationFrame(this._redrawLater.bind(this));
+    const rl: ()=>Promise<void> = this._redrawLater.bind(this)
+    requestAnimationFrame(rl);
   }
 
   _onUrl(url: string) {
@@ -101,11 +103,13 @@
     );
   }
 
-  _redrawLater() {
+  async _redrawLater() {
     if (!this.graphViewDirty) return;
 
     if ((this.graph as VersionedGraph).store && this.graph.store) {
-      this._graphAreaShowGraph(new GraphView(this.url, this.graph.store));
+      await this._graphAreaShowGraph(
+        new GraphView(this.url, this.view, this.graph.store)
+      );
       this.graphViewDirty = false;
     } else {
       this._graphAreaShowPending();
@@ -120,8 +124,8 @@
     this._setGraphArea(html` <span>waiting for data...</span> `);
   }
 
-  _graphAreaShowGraph(graphView: GraphView) {
-    this._setGraphArea(graphView.makeTemplate());
+  async _graphAreaShowGraph(graphView: GraphView) {
+    this._setGraphArea(await graphView.makeTemplate());
   }
 
   _setGraphArea(tmpl: TemplateResult) {