Skip to content

Commit 4251ece

Browse files
authored
Support watching changes on connections. (#5250)
1 parent fec04f3 commit 4251ece

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/composables/node/useWatchWidget.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,29 @@ export const useComputedWithWidgetWatch = (
7575
}
7676
})
7777
})
78+
if (widgetNames && widgetNames.length > widgetsToObserve.length) {
79+
//Inputs have been included
80+
const indexesToObserve = widgetNames
81+
.map((name) =>
82+
widgetsToObserve.some((w) => w.name == name)
83+
? -1
84+
: node.inputs.findIndex((i) => i.name == name)
85+
)
86+
.filter((i) => i >= 0)
87+
node.onConnectionsChange = useChainCallback(
88+
node.onConnectionsChange,
89+
(_type: unknown, index: number, isConnected: boolean) => {
90+
if (!indexesToObserve.includes(index)) return
91+
widgetValues.value = {
92+
...widgetValues.value,
93+
[indexesToObserve[index]]: isConnected
94+
}
95+
if (triggerCanvasRedraw) {
96+
node.graph?.setDirtyCanvas(true, true)
97+
}
98+
}
99+
)
100+
}
78101
}
79102

80103
// Returns a function that creates a computed that responds to widget changes.

0 commit comments

Comments
 (0)