Node change event types for LiveFlow.
Node changes describe mutations to nodes that are sent from the JS hook to the LiveView. These follow the xyflow pattern of immutable state changes.
Change Types
:position- Node was moved:dimensions- Node dimensions were measured/changed:select- Node selection changed:remove- Node was removed:add- Node was added:replace- Node was replaced entirely
Examples
# Position change from JS drag
%{"type" => "position", "id" => "node-1", "position" => %{"x" => 100, "y" => 200}, "dragging" => false}
# Dimensions change after node render
%{"type" => "dimensions", "id" => "node-1", "width" => 150, "height" => 50}
Summary
Functions
Applies a single change to the state.
Applies a list of changes to the state.
Creates a dimensions change.
Creates a position change.
Creates a remove change.
Creates a selection change.
Types
@type add_change() :: %{type: :add, node: map()}
@type remove_change() :: %{type: :remove, id: String.t()}
@type replace_change() :: %{type: :replace, node: map()}
@type t() :: position_change() | dimensions_change() | selection_change() | remove_change() | add_change() | replace_change()
Functions
@spec apply_change(LiveFlow.State.t(), map()) :: LiveFlow.State.t()
Applies a single change to the state.
@spec apply_changes(LiveFlow.State.t(), [map()]) :: LiveFlow.State.t()
Applies a list of changes to the state.
Creates a dimensions change.
Creates a position change.
Creates a remove change.
Creates a selection change.