Function sycamore_reactive::map_indexed[][src]

pub fn map_indexed<T, U>(
    list: ReadSignal<Vec<T>>,
    map_fn: impl Fn(&T) -> U + 'static
) -> impl FnMut() -> Vec<U> where
    T: PartialEq + Clone,
    U: Clone + 'static, 
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 by index to prevent recomputing values that have not changed.

Generally, it is preferred to use map_keyed instead when a key function is available.

This function is the underlying utility behind Indexed.

Params

  • list - The list to be mapped. The list must be a ReadSignal (obtained from a Signal) and therefore reactive.
  • map_fn - A closure that maps from the input type to the output type.