ConnectionState

Source on GitHub

The ConnectionState type bundles all information about an ongoing connection. It is returned by the useConnection hook.

type NoConnection = {
  inProgress: false;
  isValid: null;
  from: null;
  fromHandle: null;
  fromPosition: null;
  fromNode: null;
  to: null;
  toHandle: null;
  toPosition: null;
  toNode: null;
};
type ConnectionInProgress = {
  inProgress: true;
  isValid: boolean | null;
  from: XYPosition;
  fromHandle: Handle;
  fromPosition: Position;
  fromNode: NodeBase;
  to: XYPosition;
  toHandle: Handle | null;
  toPosition: Position;
  toNode: NodeBase | null;
};
 
type ConnectionState = ConnectionInProgress | NoConnection;

Fields

The ConnectionState type bundles all information about an ongoing connection. It is returned by the useConnection hook.

  • inProgress: boolean Indicates whether a connection is currently in progress.
  • isValid: boolean | null If an ongoing connection is above a handle or inside the connection radius, this will be true or false, otherwise null.
  • from: XYPosition | null Returns the xy start position or null if no connection is in progress.
  • fromHandle: Handle | null Returns the start handle or null if no connection is in progress.
  • fromPosition: Position | null Returns the side (called position) of the start handle or null if no connection is in progress.
  • fromNode: NodeType | null Returns the start node or null if no connection is in progress.
  • to: XYPosition | null Returns the xy end position or null if no connection is in progress.
  • toHandle: Handle | null Returns the end handle or null if no connection is in progress.
  • toPosition: Position | null Returns the side (called position) of the end handle or null if no connection is in progress.
  • toNode: NodeType | null Returns the end node or null if no connection is in progress.
  • pointer: XYPosition | null Returns the pointer position or null if no connection is in progress.