Mercurial > code > home > repos > streamed-graph
changeset 4:a668a774b162
back up, slowly turn on code again until ts breaks
author | drewp@bigasterisk.com |
---|---|
date | Wed, 04 Dec 2019 00:23:28 -0800 |
parents | a7ba8627a7b6 |
children | 8aa42fa04b17 |
files | src/streamed-graph.ts src/streamed_graph_client.ts tsconfig.json webpack-dev.config.ts |
diffstat | 4 files changed, 52 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/src/streamed-graph.ts Wed Dec 04 00:09:15 2019 -0800 +++ b/src/streamed-graph.ts Wed Dec 04 00:23:28 2019 -0800 @@ -7,6 +7,9 @@ import { customElement, property, computed } from '@polymer/decorators'; import { render } from 'lit-html'; // import { graphView } from '/rdf/browse/graphView.js'; + + + import { StreamedGraphClient } from './streamed_graph_client'; @customElement('streamed-graph') @@ -66,12 +69,12 @@ _onUrl(url) { // if (this.sg) { this.sg.close(); } - this.sg = new StreamedGraphClient( - url, - this.onGraphChanged.bind(this), - this.set.bind(this, 'status'), - [],//window.NS, - []); + // this.sg = new StreamedGraphClient( + // url, + // this.onGraphChanged.bind(this), + // this.set.bind(this, 'status'), + // [],//window.NS, + // []); } onGraphChanged() {
--- a/src/streamed_graph_client.ts Wed Dec 04 00:09:15 2019 -0800 +++ b/src/streamed_graph_client.ts Wed Dec 04 00:23:28 2019 -0800 @@ -10,10 +10,10 @@ const EventSource = window.EventSource; export class StreamedGraphClient { - // onStatus: (msg: string) => void; - // onGraphChanged: () => void; - // store: Store; - // events: EventSource; + onStatus: (msg: string) => void; + onGraphChanged: () => void; + store: Store; + events: EventSource; constructor( eventsUrl: string, onGraphChanged: () => void, @@ -27,14 +27,14 @@ // this.onGraphChanged = onGraphChanged; // this.onStatus('startup...'); - // this.store = new Store({}); + this.store = new Store({}); // // Object.keys(prefixes).forEach((prefix) => { // // this.store.setPrefix(prefix, prefixes[prefix]); // // }); - // this.connect(eventsUrl); - // this.reconnectOnWake(); + this.connect(eventsUrl); + this.reconnectOnWake(); // staticGraphUrls.forEach((url) => { // fetch(url).then((response) => response.text()) @@ -45,47 +45,47 @@ } - // reconnectOnWake() { - // // it's not this, which fires on every mouse-in on a browser window, and doesn't seem to work for screen-turned-back-on - // //window.addEventListener('focus', function() { this.connect(eventsUrl); }.bind(this)); + reconnectOnWake() { + // it's not this, which fires on every mouse-in on a browser window, and doesn't seem to work for screen-turned-back-on + //window.addEventListener('focus', function() { this.connect(eventsUrl); }.bind(this)); - // } + } - // connect(eventsUrl: string) { - // // need to exit here if this obj has been replaced + connect(eventsUrl: string) { + // need to exit here if this obj has been replaced - // this.onStatus('start connect...'); - // this.close(); - // if (this.events && this.events.readyState != EventSource.CLOSED) { - // this.onStatus('zombie'); - // throw new Error("zombie eventsource"); - // } + this.onStatus('start connect...'); + // this.close(); + if (this.events && this.events.readyState != EventSource.CLOSED) { + this.onStatus('zombie'); + throw new Error("zombie eventsource"); + } - // this.events = new EventSource(eventsUrl); + this.events = new EventSource(eventsUrl); - // this.events.addEventListener('error', (ev) => { - // // todo: this is piling up tons of retries and eventually multiple connections - // this.testEventUrl(eventsUrl); - // this.onStatus('connection lost- retrying'); - // setTimeout(() => { - // requestAnimationFrame(() => { - // this.connect(eventsUrl); - // }); - // }, 3000); - // }); + this.events.addEventListener('error', (ev) => { + // todo: this is piling up tons of retries and eventually multiple connections + // this.testEventUrl(eventsUrl); + this.onStatus('connection lost- retrying'); + setTimeout(() => { + requestAnimationFrame(() => { + this.connect(eventsUrl); + }); + }, 3000); + }); - // this.events.addEventListener('fullGraph', (ev) => { - // // this.updates.push({ type: 'fullGraph', data: ev.data }); - // // this.flushUpdates(); - // }); + this.events.addEventListener('fullGraph', (ev) => { + // this.updates.push({ type: 'fullGraph', data: ev.data }); + // this.flushUpdates(); + }); - // this.events.addEventListener('patch', (ev) => { - // // this.updates.push({ type: 'patch', data: ev.data }); - // // this.flushUpdates(); - // }); - // this.onStatus('connecting...'); - // } + this.events.addEventListener('patch', (ev) => { + // this.updates.push({ type: 'patch', data: ev.data }); + // this.flushUpdates(); + }); + this.onStatus('connecting...'); + } // replaceFullGraph(jsonLdText: string, done: () => void) { // // this.quadStore.clear();
--- a/tsconfig.json Wed Dec 04 00:09:15 2019 -0800 +++ b/tsconfig.json Wed Dec 04 00:23:28 2019 -0800 @@ -5,13 +5,13 @@ "target": "es6", "rootDirs": [ "node_modules", - "src" + // "src" ], "esModuleInterop": true, "allowSyntheticDefaultImports": true }, "files": [ "./src/streamed-graph.ts", - "./src/streamed_graph_client.ts" + // "./src/streamed_graph_client.ts" ] }
--- a/webpack-dev.config.ts Wed Dec 04 00:09:15 2019 -0800 +++ b/webpack-dev.config.ts Wed Dec 04 00:23:28 2019 -0800 @@ -5,7 +5,7 @@ mode: "development", entry: [ './src/streamed-graph.ts', - './src/streamed_graph_client.ts', + // './src/streamed_graph_client.ts', './src/streamed-graph.css' // doesn't emit anything ],