# `LiveFlow.Handle`
[🔗](https://github.com/rocket4ce/live_flow/blob/main/lib/live_flow/core/handle.ex#L1)

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`)
  * `:offset` - Where the handle sits along its side, from `0.0` (top/left)
    to `1.0` (bottom/right); edges attach there (default: `0.5`, the center)
  * `: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}

# `t`

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

# `effective_id`

```elixir
@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`

```elixir
@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`)
  * `:offset` - Position along the side, `0.0`..`1.0` (default: `0.5`)
  * `: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`

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

Creates a source handle (output).

# `source?`

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

Checks if the handle is a source (output).

# `target`

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

Creates a target handle (input).

# `target?`

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

Checks if the handle is a target (input).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
