sycamore::reactive

Function map_indexed

pub fn map_indexed<T, U>(
    list: impl Into<MaybeDyn<Vec<T>>> + 'static,
    map_fn: impl FnMut(T) -> U + 'static,
) -> ReadSignal<Vec<U>>
where T: PartialEq + Clone + 'static, U: Clone,
Expand description

Function that maps a Vec to another Vec via a map function.

The mapped Vec is lazily 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.