LiveFlow.Handle (LiveFlow v0.2.3)

Copy Markdown View Source

Handle data structure for LiveFlow.

A handle is a connection point on a node that allows edges to be connected. Handles can be either source (output) or target (input).

Fields

  • :id - Optional unique identifier within the node
  • :type - Handle type: :source or :target
  • :position - Position on the node: :top, :bottom, :left, :right
  • :connectable - Whether this handle accepts connections
  • :connect_type - Optional type constraint atom (e.g., :data, :control)
  • :style - Custom inline styles
  • :class - Custom CSS classes

Examples

iex> LiveFlow.Handle.new(:source, :bottom)
%LiveFlow.Handle{type: :source, position: :bottom}

iex> LiveFlow.Handle.new(:target, :top, id: "input-1")
%LiveFlow.Handle{id: "input-1", type: :target, position: :top}

Summary

Functions

Returns the effective ID for the handle.

Creates a new handle with the given type and position.

Creates a source handle (output).

Checks if the handle is a source (output).

Creates a target handle (input).

Checks if the handle is a target (input).

Types

t()

@type t() :: %LiveFlow.Handle{
  class: String.t() | nil,
  connect_type: atom() | nil,
  connectable: boolean(),
  id: String.t() | nil,
  position: :top | :bottom | :left | :right,
  style: map(),
  type: :source | :target
}

Functions

effective_id(handle)

@spec effective_id(t()) :: String.t()

Returns the effective ID for the handle.

If no ID is set, returns the type as a string.

new(type, position, opts \\ [])

@spec new(:source | :target, :top | :bottom | :left | :right, keyword()) :: t()

Creates a new handle with the given type and position.

Options

  • :id - Handle ID (default: nil, will use type as identifier)
  • :connectable - Whether connectable (default: true)
  • :connect_type - Type constraint atom for validation (default: nil)
  • :style - Custom inline styles
  • :class - Custom CSS classes

Examples

iex> LiveFlow.Handle.new(:source, :right)
%LiveFlow.Handle{type: :source, position: :right}

iex> LiveFlow.Handle.new(:target, :left, id: "in", connectable: false)
%LiveFlow.Handle{id: "in", type: :target, position: :left, connectable: false}

source(position, opts \\ [])

@spec source(
  :top | :bottom | :left | :right,
  keyword()
) :: t()

Creates a source handle (output).

source?(arg1)

@spec source?(t()) :: boolean()

Checks if the handle is a source (output).

target(position, opts \\ [])

@spec target(
  :top | :bottom | :left | :right,
  keyword()
) :: t()

Creates a target handle (input).

target?(arg1)

@spec target?(t()) :: boolean()

Checks if the handle is a target (input).