Mercurial > code > home > repos > streamed-graph
changeset 146:9347277e8311
try a bit harder to notice <sg-source> children after <streamed-graph> startup
author | drewp@bigasterisk.com |
---|---|
date | Mon, 08 May 2023 13:52:50 -0700 |
parents | 3774ce9317a1 |
children | d3b7629536a1 |
files | src/ConfiguredSources.ts src/MultiStore.ts src/elements/streamed-graph/StreamedGraph.ts |
diffstat | 3 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ConfiguredSources.ts Mon May 08 13:31:46 2023 -0700 +++ b/src/ConfiguredSources.ts Mon May 08 13:52:50 2023 -0700 @@ -46,7 +46,6 @@ newSourceGraph(s: SourceGraph) { this.graph.newStore(s); - this.viewConfigMaybeChanged(); } lostSourceGraph(s: SourceGraph) {
--- a/src/MultiStore.ts Mon May 08 13:31:46 2023 -0700 +++ b/src/MultiStore.ts Mon May 08 13:52:50 2023 -0700 @@ -27,6 +27,11 @@ } newStore(s: SourceGraph) { + for (let ts of this.stores) { + if (ts==s.store) { + return; + } + } this.stores.push(s.store); const p = new Patch(PatchDirection.ADD); // todo s.sourceGraphChanged.subscribe((p) => {
--- a/src/elements/streamed-graph/StreamedGraph.ts Mon May 08 13:31:46 2023 -0700 +++ b/src/elements/streamed-graph/StreamedGraph.ts Mon May 08 13:52:50 2023 -0700 @@ -23,6 +23,8 @@ @property() viewConfig: ViewConfig; // immutable, rebuilt when page or graph changes (in relevant ways) @state() statusSummary: TemplateResult[] = [html`...`]; + private observeChildren?: MutationObserver; + // @state() viewDirty: number = 0; static styles = [streamedGraphStyle]; constructor() { @@ -44,6 +46,10 @@ firstUpdated(ch: PropertyValueMap<this>): void { super.firstUpdated(ch); this.scanChildNodesOnce(); + this.observeChildren = new MutationObserver(() => + this.scanChildNodesOnce() + ); + this.observeChildren.observe(this, { childList: true }); addFontToRootPage(); } @@ -77,6 +83,8 @@ const st = el.sourceGraph; if (st) { this.sources.newSourceGraph(st); + } else { + console.warn("el has no sourceGraph yet", el); } }