Function map_keyed
pub fn map_keyed<T, K, U>(
list: impl Into<MaybeDyn<Vec<T>>> + 'static,
map_fn: impl FnMut(T) -> U + 'static,
key_fn: impl Fn(&T) -> K + 'static,
) -> ReadSignal<Vec<U>>
Expand description
Function that maps a Vec
to another Vec
via a map function and a key.
The mapped Vec
is lazily computed, meaning that it’s value will only be updated when
requested. Modifications to the input Vec
are diffed using keys to prevent recomputing values
that have not changed.
This function is the underlying utility behind Keyed
.
§Params
list
- The list to be mapped. The list must be aReadSignal
(obtained from aSignal
) and therefore reactive.map_fn
- A closure that maps from the input type to the output type.key_fn
- A closure that returns an unique key to each entry.
Credits: Based on TypeScript implementation in https://github.com/solidjs/solid