@@ -13,6 +13,8 @@ export interface UseHandleConnectionsParams {
13
13
onDisconnect ?: ( connections : Connection [ ] ) => void
14
14
}
15
15
16
+ // todo: add edge id to connection params
17
+
16
18
/**
17
19
* Composable that returns existing connections of a handle
18
20
*
@@ -39,6 +41,8 @@ export function useHandleConnections(params: UseHandleConnectionsParams): Comput
39
41
40
42
const handleId = toRef ( ( ) => toValue ( id ) ?? null )
41
43
44
+ const prevConnections = ref < Map < string , Connection > | null > ( null )
45
+
42
46
const connections = ref < Map < string , Connection > > ( )
43
47
44
48
watch (
@@ -55,12 +59,14 @@ export function useHandleConnections(params: UseHandleConnectionsParams): Comput
55
59
56
60
watch (
57
61
[ connections , ( ) => typeof onConnect !== 'undefined' , ( ) => typeof onDisconnect !== 'undefined' ] ,
58
- ( [ currentConnections ] , [ prevConnections ] ) => {
59
- if ( prevConnections && prevConnections !== currentConnections ) {
62
+ ( [ currentConnections ] ) => {
63
+ if ( prevConnections . value && prevConnections . value !== currentConnections ) {
60
64
const _connections = currentConnections ?? new Map ( )
61
- handleConnectionChange ( prevConnections , _connections , onDisconnect )
62
- handleConnectionChange ( _connections , prevConnections , onConnect )
65
+ handleConnectionChange ( prevConnections . value , _connections , onDisconnect )
66
+ handleConnectionChange ( _connections , prevConnections . value , onConnect )
63
67
}
68
+
69
+ prevConnections . value = currentConnections ?? new Map ( )
64
70
} ,
65
71
{ immediate : true } ,
66
72
)
0 commit comments