Masu.Source.List (Masu v0.1.0)

Copy Markdown View Source

The source of a grid given its rows: <.data_grid rows={@users}>.

The rows are maps or structs. The list filters, searches and sorts them in the LiveView's process when the query changes, once, and keeps the result as a tuple, so each block the browser asks for is read without walking the list. Sorting a hundred thousand rows takes a fraction of a second; past that, give the grid an Ecto source and let the database do it.

Text sorts without case, nil after every value, and rows that compare equal keep their order in the list.

A tree

With the grid's tree (a field of the row that holds its parent's id, or a function of the row), the rows are a tree (Masu.Tree): the list holds every row, and the grid shows the roots and the children of the rows that are open.