changeset 2270:b51c74da9d35

more cleanup- mixed up with other commits
author drewp@bigasterisk.com
date Mon, 29 May 2023 13:22:44 -0700
parents cd4a9eeeb9e6
children 698da65519a3
files light9/web/AutoDependencies.ts light9/web/RdfdbSyncedGraph.ts light9/web/SyncedGraph.ts
diffstat 3 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/AutoDependencies.ts	Mon May 29 13:21:14 2023 -0700
+++ b/light9/web/AutoDependencies.ts	Mon May 29 13:22:44 2023 -0700
@@ -2,16 +2,11 @@
 import { NamedNode, Quad_Graph, Quad_Object, Quad_Predicate, Quad_Subject, Term, Util } from "n3";
 import { filter } from "underscore";
 import { Patch, QuadPattern } from "./patch";
+import { SubEvent } from "sub-events";
+import { SyncedGraph } from "./SyncedGraph";
 
 const log = debug("autodep");
 
-interface QuadPattern {
-  subject: Quad_Subject | null;
-  predicate: Quad_Predicate | null;
-  object: Quad_Object | null;
-  graph: Quad_Graph | null;
-}
-
 // use patch as an optional optimization, but you can't count on it
 export type HandlerFunc = (p?: Patch) => void;
 
@@ -28,7 +23,8 @@
 export class AutoDependencies {
   handlers: Handler;
   handlerStack: Handler[];
-  constructor() {
+  graphError: SubEvent<string> = new SubEvent();
+  constructor(private graph: SyncedGraph) {
     // tree of all known Handlers (at least those with non-empty
     // patterns). Top node is not a handler.
     this.handlers = new Handler(null, "root");
@@ -75,6 +71,7 @@
       this.handlerStack.pop();
     }
   }
+
   // handler might have no watches, in which case we could forget about it
   logHandlerTree() {
     log("handler tree:");
--- a/light9/web/RdfdbSyncedGraph.ts	Mon May 29 13:21:14 2023 -0700
+++ b/light9/web/RdfdbSyncedGraph.ts	Mon May 29 13:22:44 2023 -0700
@@ -33,6 +33,7 @@
     const prefixes = new Map<string, string>([
       ["", "http://light9.bigasterisk.com/"],
       ["dev", "http://light9.bigasterisk.com/device/"],
+      ["effect", "http://light9.bigasterisk.com/effect/"],
       ["rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"],
       ["rdfs", "http://www.w3.org/2000/01/rdf-schema#"],
       ["xsd", "http://www.w3.org/2001/XMLSchema#"],
--- a/light9/web/SyncedGraph.ts	Mon May 29 13:21:14 2023 -0700
+++ b/light9/web/SyncedGraph.ts	Mon May 29 13:22:44 2023 -0700
@@ -36,6 +36,10 @@
     this.prefixFuncs = this.rebuildPrefixFuncs(prefixes);
     this.graph = new N3.Store();
     this.autoDeps = new AutoDependencies(this);
+    this.autoDeps.graphError.subscribe((e) => {
+      log("graph learned of error - reconnecting", e);
+      this.client.disconnect();
+    });
     this.clearGraph();
 
     this.client = new RdfDbClient(patchSenderUrl, this._clearGraphOnNewConnection.bind(this), this._applyPatch.bind(this), this.setStatus);