pub fn map_keyed<'a, T, K, U>(
cx: BoundedScope<'a, 'a>,
list: &'a ReadSignal<Vec<T, Global>>,
map_fn: impl for<'child_lifetime> Fn(BoundedScope<'child_lifetime, 'a>, T) -> U + 'a,
key_fn: impl Fn(&T) -> K + 'a
) -> &'a ReadSignal<Vec<U, Global>>where
T: PartialEq<T> + Clone,
K: Eq + Hash,
U: Clone,
Expand description
Function that maps a Vec
to another Vec
via a map function. The mapped Vec
is lazy
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