Events and errors
Node clicks
Section titled “Node clicks”const stop = graph.on("nodeClick", ({ nodeId }) => { detailPanel.show(nodeId);});Node ids are strings at the browser-driver boundary.
Story changes
Section titled “Story changes”graph.on("stepChange", ({ index, title }) => { chapterNav.select(index, title);});The event fires when the current story step changes through the host or the embedded player.
Renderer errors
Section titled “Renderer errors”graph.on("error", ({ message }) => { showGraphError(message);});Method calls reject when a project or parameter is invalid, a command is not granted, or the renderer does not reply before the timeout.
try { await graph.setDocument(candidate);} catch (error) { console.error("Garphield rejected the project", error);}Cleanup
Section titled “Cleanup”Keep the unsubscribe functions returned by on(). Call them, then call
destroy() before permanently removing the iframe.