Skip to content

Commit 471aad9

Browse files
committed
Graph view: only load wasm once on mount
1 parent 6866fb9 commit 471aad9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/views/Graph.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,12 @@ export default {
294294
}
295295
},
296296
297-
mounted () {
297+
async mounted () {
298+
// compile & instantiate graphviz wasm
299+
this.graphviz = await Graphviz.load()
298300
// allow render to happen before we go configuring svgPanZoom
299-
const self = this
300-
this.$nextTick(function () {
301-
self.updateTimer()
301+
this.$nextTick(() => {
302+
this.updateTimer()
302303
})
303304
this.mountSVGPanZoom()
304305
},
@@ -586,7 +587,7 @@ export default {
586587
587588
// layout the graph
588589
try {
589-
await this.layout(nodes, edges, nodeDimensions)
590+
this.layout(nodes, edges, nodeDimensions)
590591
} catch (e) {
591592
// something went wrong, allow the layout to retry later
592593
this.graphID = null
@@ -624,14 +625,12 @@ export default {
624625
}
625626
},
626627
/** re-layout the graph after any new nodes have been rendered */
627-
async layout (nodes, edges, nodeDimensions) {
628-
const graphviz = await Graphviz.load()
629-
628+
layout (nodes, edges, nodeDimensions) {
630629
// generate the GraphViz dot code
631630
const dotCode = this.getDotCode(nodeDimensions, nodes, edges)
632631
633632
// run the layout algorithm
634-
const jsonString = graphviz.layout(dotCode, 'json')
633+
const jsonString = this.graphviz.layout(dotCode, 'json')
635634
const json = JSON.parse(jsonString)
636635
637636
// update graph node positions

0 commit comments

Comments
 (0)