refactor(core): allow null instead of undefined as id for useHandleConnections
This commit is contained in:
@@ -9,8 +9,8 @@ import { useVueFlow } from './useVueFlow'
|
|||||||
|
|
||||||
interface UseHandleConnectionsParams {
|
interface UseHandleConnectionsParams {
|
||||||
type: MaybeRefOrGetter<HandleType>
|
type: MaybeRefOrGetter<HandleType>
|
||||||
id?: MaybeRefOrGetter<string | undefined>
|
id?: MaybeRefOrGetter<string | null>
|
||||||
nodeId?: MaybeRefOrGetter<string | undefined>
|
nodeId?: MaybeRefOrGetter<string | null>
|
||||||
onConnect?: (connections: Connection[]) => void
|
onConnect?: (connections: Connection[]) => void
|
||||||
onDisconnect?: (connections: Connection[]) => void
|
onDisconnect?: (connections: Connection[]) => void
|
||||||
}
|
}
|
||||||
@@ -35,13 +35,19 @@ export function useHandleConnections({
|
|||||||
onDisconnect,
|
onDisconnect,
|
||||||
}: UseHandleConnectionsParams): ComputedRef<Connection[]> {
|
}: UseHandleConnectionsParams): ComputedRef<Connection[]> {
|
||||||
const { connectionLookup } = useVueFlow()
|
const { connectionLookup } = useVueFlow()
|
||||||
|
|
||||||
const _nodeId = useNodeId()
|
const _nodeId = useNodeId()
|
||||||
const currentNodeId = toRef(() => toValue(nodeId) || _nodeId)
|
|
||||||
|
const currentNodeId = toRef(() => toValue(nodeId) ?? _nodeId)
|
||||||
|
|
||||||
|
const handleType = toRef(() => toValue(type))
|
||||||
|
|
||||||
|
const handleId = toRef(() => toValue(id) ?? null)
|
||||||
|
|
||||||
const connections = ref<Map<string, Connection>>()
|
const connections = ref<Map<string, Connection>>()
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => connectionLookup.value.get(`${currentNodeId.value}-${toValue(type)}-${toValue(id)}`),
|
() => connectionLookup.value.get(`${currentNodeId.value}-${handleType.value}-${handleId.value}`),
|
||||||
(nextConnections) => {
|
(nextConnections) => {
|
||||||
if (areConnectionMapsEqual(connections.value, nextConnections)) {
|
if (areConnectionMapsEqual(connections.value, nextConnections)) {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user