Public API for diff operations.
This module delegates to Dala.Ui.Diff for computing UI tree diffs.
Summary
Functions
Compute the diff between two UI trees.
Types
@type patch() :: {:replace, node_id(), Dala.Node.t()} | {:update_props, node_id(), map()} | {:insert, node_id(), non_neg_integer(), Dala.Node.t()} | {:remove, node_id()}
Functions
@spec diff(Dala.Node.t() | nil, Dala.Node.t() | nil) :: [patch()]
Compute the diff between two UI trees.
Returns a list of patches to transform old_tree into new_tree.
Examples
old_tree = Dala.Node.from_map(%{id: "root", type: :text, props: %{text: "Hello"}}, "root")
new_tree = Dala.Node.from_map(%{id: "root", type: :text, props: %{text: "World"}}, "root")
patches = Dala.Diff.diff(old_tree, new_tree)