legos/keyed

Values

pub fn column(
  attrs: List(@internal Attribute(@internal Aligned, msg)),
  children: List(#(String, @internal Element(msg))),
) -> @internal Element(msg)

Create a keyed column layout with a list of keyed children. Each child is paired with a string key for efficient diffing.

pub fn el(
  attrs: List(@internal Attribute(@internal Aligned, msg)),
  child: #(String, @internal Element(msg)),
) -> @internal Element(msg)

Create a keyed element that helps optimize cases where children are getting added, moved, removed, etc. Common examples include:

  • The user can delete items from a list
  • The user can create new items in a list
  • You can sort a list based on name or date or whatever

When you use a keyed element, every child is paired with a string identifier. This makes it possible for the underlying diffing algorithm to reuse nodes more efficiently.

This means if a key is changed between renders, then the diffing step will be skipped and the node will be forced to rerender.

pub fn row(
  attrs: List(@internal Attribute(@internal Aligned, msg)),
  children: List(#(String, @internal Element(msg))),
) -> @internal Element(msg)

Create a keyed row layout with a list of keyed children. Each child is paired with a string key for efficient diffing.

Search Document