fix(core): ensure events introduced by the watcher are released when no longer needed
This commit is contained in:
@@ -134,7 +134,7 @@ export function useVueFlow(options?: FlowProps): VueFlowStore {
|
|||||||
detachedScope.run(() => {
|
detachedScope.run(() => {
|
||||||
watch(
|
watch(
|
||||||
state.applyDefault,
|
state.applyDefault,
|
||||||
(shouldApplyDefault) => {
|
(shouldApplyDefault, __, onCleanup) => {
|
||||||
const nodesChangeHandler = (changes: NodeChange[]) => {
|
const nodesChangeHandler = (changes: NodeChange[]) => {
|
||||||
state.applyNodeChanges(changes)
|
state.applyNodeChanges(changes)
|
||||||
}
|
}
|
||||||
@@ -150,6 +150,11 @@ export function useVueFlow(options?: FlowProps): VueFlowStore {
|
|||||||
state.hooks.value.nodesChange.off(nodesChangeHandler)
|
state.hooks.value.nodesChange.off(nodesChangeHandler)
|
||||||
state.hooks.value.edgesChange.off(edgesChangeHandler)
|
state.hooks.value.edgesChange.off(edgesChangeHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCleanup(() => {
|
||||||
|
state.hooks.value.nodesChange.off(nodesChangeHandler)
|
||||||
|
state.hooks.value.edgesChange.off(edgesChangeHandler)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user