A library for lists of things you want to track, kind of like Html.Keyed but for your data model.
A list with no items.
Attach a new item to the beginning of the list.
Attach a new item to the end of the list.
Convert a List to a KeyedList, preserving the order of the items.
Update the value of a list for a specific Key with a given function.
Remove an item from a list by Key. If the Key is not found, no changes are made.
Convert to a regular List. Useful if you need to convert to JSON.
Create a List out of items and their Keys. This is particularly useful in the view of a Model that contains a KeyedList.
type alias Model =
{ submodels : KeyedList SubModel
...
}
view : Model -> Html Msg
view model =
keyedMap viewKeyedSubmodel model.submodels
|> div []
viewKeyedSubmodel : Key -> SubModel -> Html Msg
viewKeyedSubmodel key submodel =
div [ onClick <| Click key ] [ SubModel.view submodel ]Check if a list is currently empty
Get the current length of a list
Keep only elements that satisfy the predicate, preserving Keys.
Apply a function to every item in a list, preserving Keys.
A list that gives each element a locally unique
Keyfor later modification or removal.Convert a list using
fromListor build one from scratch withemptyandpush.