LiveDebugger.Structs.TreeNode (LiveDebugger v0.1.4)
View SourceThis module provides functions to work with the tree of LiveView and LiveComponent nodes (TreeNodes).
Summary
Functions
Adds a child to the parent node.
Returns string representation of the node's ID, ready to be displayed in the UI.
Returns a child of the parent node by PID or CID.
Returns PID or CID of the node.
Parses ID from string to PID or CID.
Same as id_from_string/1
, but raises an ArgumentError if the ID is invalid.
Parses channel_state state to LiveDebugger.Structs.TreeNode.LiveComponent of given CID.
If the component is not found, returns nil
.
Parses channel_state to a list of all LiveDebugger.Structs.TreeNode.LiveComponent nodes. It doesn't include children.
Parses channel_state to LiveDebugger.Structs.TreeNode.LiveView.
Gives type of the node. Types
Types
Functions
Adds a child to the parent node.
Returns string representation of the node's ID, ready to be displayed in the UI.
Returns a child of the parent node by PID or CID.
Returns PID or CID of the node.
Parses ID from string to PID or CID.
Same as id_from_string/1
, but raises an ArgumentError if the ID is invalid.
@spec live_component_node( channel_state :: LiveDebugger.CommonTypes.channel_state(), cid :: cid() ) :: {:ok, t() | nil} | {:error, term()}
Parses channel_state state to LiveDebugger.Structs.TreeNode.LiveComponent of given CID.
If the component is not found, returns nil
.
Examples
iex> {:ok, state} = LiveDebugger.Services.LiveViewDiscoveryService.channel_state_from_pid(pid)
iex> LiveDebugger.Structs.TreeNode.live_component_node(state, 2)
{:ok, %LiveDebugger.Structs.TreeNode.LiveComponent{cid: 2, ...}}
iex> {:ok, state} = LiveDebugger.Services.LiveViewDiscoveryService.channel_state_from_pid(pid)
iex> LiveDebugger.Structs.TreeNode.live_component_node(state, 999)
{:ok, nil}
@spec live_component_nodes(channel_state :: LiveDebugger.CommonTypes.channel_state()) :: {:ok, [t()]} | {:error, term()}
Parses channel_state to a list of all LiveDebugger.Structs.TreeNode.LiveComponent nodes. It doesn't include children.
Examples
iex> {:ok, state} = LiveDebugger.Services.get_channel_state(pid)
iex> LiveDebugger.Structs.TreeNode.live_component_nodes(state)
{:ok, [%LiveDebugger.Structs.TreeNode.LiveComponent{...}, ...]}
@spec live_view_node(channel_state :: LiveDebugger.CommonTypes.channel_state()) :: {:ok, t()} | {:error, term()}
Parses channel_state to LiveDebugger.Structs.TreeNode.LiveView.
Examples
iex> {:ok, state} = LiveDebugger.Services.LiveViewDiscoveryService.channel_state_from_pid(pid)
iex> LiveDebugger.Structs.TreeNode.live_view_node(state)
{:ok, %LiveDebugger.Structs.TreeNode.LiveView{...}}
Gives type of the node. Types:
:live_view
:live_component