LiveFlow.Changes.EdgeChange (LiveFlow v0.4.0)

Copy Markdown View Source

Edge change event types for LiveFlow.

Edge changes describe mutations to edges that are sent from the JS hook to the LiveView.

Change Types

  • :add - Edge was added (connection made)
  • :remove - Edge was removed
  • :select - Edge selection changed
  • :replace - Edge was replaced

Examples

# Edge added from connection
%{"type" => "add", "edge" => %{"id" => "e1", "source" => "a", "target" => "b"}}

# Edge selection
%{"type" => "select", "id" => "e1", "selected" => true}

Summary

Functions

Creates an add edge change.

Applies a single change to the state.

Applies a list of changes to the state.

Creates a remove edge change.

Creates a selection change.

Types

add_change()

@type add_change() :: %{type: :add, edge: map()}

remove_change()

@type remove_change() :: %{type: :remove, id: String.t()}

replace_change()

@type replace_change() :: %{type: :replace, edge: map()}

selection_change()

@type selection_change() :: %{type: :select, id: String.t(), selected: boolean()}

t()

Functions

add(edge_data)

@spec add(map()) :: map()

Creates an add edge change.

apply_change(state, change)

@spec apply_change(LiveFlow.State.t(), map()) :: LiveFlow.State.t()

Applies a single change to the state.

apply_changes(state, changes)

@spec apply_changes(LiveFlow.State.t(), [map()]) :: LiveFlow.State.t()

Applies a list of changes to the state.

remove(id)

@spec remove(String.t()) :: map()

Creates a remove edge change.

select(id, selected)

@spec select(String.t(), boolean()) :: map()

Creates a selection change.