Function leptos_core::map_keyed
source · pub fn map_keyed<T, U, K>(
cx: Scope,
list: impl Fn() -> Vec<T> + 'static,
map_fn: impl Fn(Scope, &T) -> U + 'static,
key_fn: impl Fn(&T) -> K + 'static
) -> Memo<Vec<U>>where
T: PartialEq + Debug + 'static,
K: Eq + Hash,
U: PartialEq + Debug + Clone + 'static,
Expand description
Function that maps a Vec
to another Vec
via a map function. The mapped Vec
is lazy
computed; its 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. It is obtained via an accessor function, so can be a ReadSignal, a Memo or a derived signal.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 implementation for Sycamore, which is in turned based on on the TypeScript implementation in https://github.com/solidjs/solid