chore(core): cleanup

This commit is contained in:
braks
2024-02-05 07:51:12 +01:00
committed by Braks
parent 3f5519da4d
commit 0941e609dd
3 changed files with 44 additions and 3 deletions
+8
View File
@@ -3,3 +3,11 @@
---
Add `useNodeId` composable
## 🧙 Example
```ts
const nodeId = useNodeId()
console.log('nodeId', nodeId) // '1'
```
+33
View File
@@ -3,3 +3,36 @@
---
Add `useHandleConnections` composable
## 🧙 Example
```ts
const connections = useHandleConnections({
// type of the handle you are looking for - accepts a `MaybeRefOrGetter<string>`
type: 'source',
// the id of the handle you are looking for - accepts a `MaybeRefOrGetter<string | undefined> | undefined` [OPTIONAL]
id: 'a',
// if not provided, the node id from the NodeIdContext is used - accepts a `MaybeRefOrGetter<string | undefined> | undefined`
nodeId: '1',
// a cb that is called when a new connection is added
onConnect: (params) => {
console.log('onConnect', params)
},
// a cb that is called when a connection is removed
onDisconnect: (params) => {
console.log('onDisconnect', params)
},
})
watch(
connections,
(next) => {
console.log('connections', next)
},
{ immediate: true },
)
```
@@ -9,8 +9,8 @@ import { useVueFlow } from './useVueFlow'
interface UseHandleConnectionsParams {
type: MaybeRefOrGetter<HandleType>
id?: MaybeRefOrGetter<string | null>
nodeId?: MaybeRefOrGetter<string>
id?: MaybeRefOrGetter<string | undefined>
nodeId?: MaybeRefOrGetter<string | undefined>
onConnect?: (connections: Connection[]) => void
onDisconnect?: (connections: Connection[]) => void
}
@@ -28,7 +28,7 @@ interface UseHandleConnectionsParams {
*/
export function useHandleConnections({
type,
id = null,
id,
nodeId,
onConnect,
onDisconnect,