refactor(core): trim per-instance setup in Node/EdgeWrapper#2160
Merged
Conversation
These internal composables created a second set of 9 ExtendedEventHooks per node and per edge whose only listener forwarded to the global `emits` hooks. NodeWrapper/EdgeWrapper now call emits.node*/emits.edge* directly — identical dispatch (the global hooks in store/hooks.ts back both the on* subscriptions and the Vue @event emitter), minus 9 hook instances + 9 forwarding closures of setup cost and memory per element. Drops the now-unused NodeEventsEmit/ EdgeEventsEmit types. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: 3df3093 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
NodeWrapper used the public `useNode` composable but only ever read its `node`. Resolve the InternalNode with `computed(() => getInternalNode(id))` directly — identical to useNode's `node` — dropping the unused parentNode/connectedEdges computeds, the nodeEl inject, and a redundant useVueFlow/useStore resolution that useNode allocated per node. `useNode` stays unchanged for custom-node use. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related per-instance trims in the element wrappers — identical dispatch/behavior, less allocated per node/edge on the mount path.
1. Drop the per-wrapper
useNodeHooks/useEdgeHooksThese internal composables created, per
NodeWrapper/EdgeWrapperinstance, a second set of 9ExtendedEventHooks whose only.onlistener forwarded to the globalemitshooks — then handed the triggers back asemit. Soemit.click(x)was justemits.nodeClick(x)with an extra hop.The canonical hub is the global hook set in
store/hooks.ts(these back bothonNodeClick/onEdgeClickand the Vue@node-clickemitter viauseHooks); the per-wrapper layer had no other subscribers.NodeWrapper/EdgeWrappercallemits.node*/emits.edge*(and unprefixedemits.reconnect*) directly.useNodeHooks.ts/useEdgeHooks.ts+ theircomposables/index.tsexports.NodeEventsEmit/EdgeEventsEmittypes (*EventsOn/*EventsHandlerstay — they back the publicon*API).Drops 9 hook instances + 9 forwarding closures per node and per edge.
2.
NodeWrapperresolves its node via a direct computedNodeWrapperused the publicuseNodecomposable but only ever read itsnode. It now resolves theInternalNodewithcomputed(() => getInternalNode(id))(identical touseNode().node), dropping the unusedparentNode/connectedEdgescomputeds, thenodeElinject, and a redundantuseVueFlow/useStoreresolution thatuseNodeallocated per node.useNodeis unchanged for custom-node use. (EdgeWrapperalready resolved its edge this way.)Why
Both are zero behavioral change — same dispatch, same
noderesolution — but trim per-instance setup cost + retained memory. No public runtime API change (the hooks were@internal;useNodestays public).Tests
Full interaction suite green (21/21):
drag(nodeDragStart/Drag/Stop),connect,looseReconnect(reconnect*),selectionClickVsDrag,vmodel,basic(click/mouse),onBeforeDelete,edgeZIndex.🤖 Generated with Claude Code