chore(core): cleanup
This commit is contained in:
@@ -3,3 +3,11 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
Add `useNodeId` composable
|
Add `useNodeId` composable
|
||||||
|
|
||||||
|
## 🧙 Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const nodeId = useNodeId()
|
||||||
|
|
||||||
|
console.log('nodeId', nodeId) // '1'
|
||||||
|
```
|
||||||
|
|||||||
@@ -3,3 +3,36 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
Add `useHandleConnections` composable
|
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 {
|
interface UseHandleConnectionsParams {
|
||||||
type: MaybeRefOrGetter<HandleType>
|
type: MaybeRefOrGetter<HandleType>
|
||||||
id?: MaybeRefOrGetter<string | null>
|
id?: MaybeRefOrGetter<string | undefined>
|
||||||
nodeId?: MaybeRefOrGetter<string>
|
nodeId?: MaybeRefOrGetter<string | undefined>
|
||||||
onConnect?: (connections: Connection[]) => void
|
onConnect?: (connections: Connection[]) => void
|
||||||
onDisconnect?: (connections: Connection[]) => void
|
onDisconnect?: (connections: Connection[]) => void
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ interface UseHandleConnectionsParams {
|
|||||||
*/
|
*/
|
||||||
export function useHandleConnections({
|
export function useHandleConnections({
|
||||||
type,
|
type,
|
||||||
id = null,
|
id,
|
||||||
nodeId,
|
nodeId,
|
||||||
onConnect,
|
onConnect,
|
||||||
onDisconnect,
|
onDisconnect,
|
||||||
|
|||||||
Reference in New Issue
Block a user