Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document new connection callback API and useConnection hook. #472

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

hayleigh-dot-dev
Copy link
Contributor

We tweaked the types of useConnection, onConnectEnd, and onReconnectEnd slightly. This PR updates the docs to reflect the new API. It also documents the InternalNode type as that was being referenced without being documented.

Closes #471.

Copy link

vercel bot commented Aug 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
reactflow-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 10:23pm
svelteflow-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 10:23pm
xyflow-svelte-examples ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 10:23pm
xyflow-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 19, 2024 10:23pm

@@ -365,9 +365,11 @@ export const edgeEventHandlerProps: PropsTableProps = {
},
{
name: 'onReconnectEnd',
type: '(event: React.MouseEvent, edge: Edge, handleType: "source" | "target") => void',
type: '(event: React.MouseEvent, edge: Edge, handleType: "source" | "target", connectionState: Omit<ConnectionState, \'inProgress\'>) => void',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We created a new type LastConnectionType for this. Could you use it here and for onConnectEnd too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find a reference to a LastConnectionType in the codebase? Both onConnectEnd and onReconnectEnd use connectionState: FinalConnectionState where FinalConnectionState is a type alias for the type documented above.

See: https://github.com/xyflow/xyflow/blob/7b8fe28b37f79dd80ed0f915b834f2f61c57b73e/packages/system/src/types/general.ts#L53 and https://github.com/xyflow/xyflow/blob/7b8fe28b37f79dd80ed0f915b834f2f61c57b73e/packages/system/src/xyhandle/types.ts#L37


I can make a page for FinalConnectionState but it felt a little superfluous to have a separate page for a type identical to ConnectionState save for one field. Your call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that make sense. If some one asks, we can still add it.

@moklick moklick merged commit 54640a0 into main Aug 28, 2024
5 checks passed
@moklick moklick deleted the docs/new-connection-callbacks branch August 28, 2024 22:07
@moklick
Copy link
Member

moklick commented Aug 28, 2024

Good idea to document InternalNode as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document new useConnection and onConnectEnd params
2 participants