leptos_use::math

Function use_min

Source
pub fn use_min<C, S, N>(container: S) -> Signal<Option<N>>
where S: Into<MaybeSignal<C>>, C: 'static, for<'a> &'a C: IntoIterator<Item = &'a N>, N: PartialOrd + Clone,
Expand description

Reactive min().

Works with any container that implements IntoIterator (Vec, HashSet, …) with any elements that implement PartialOrd and Clone (floats, ints, strings, …).

If the container is empty or only contains non comparable values like NaN, it returns None. Otherwise it returns the Some(<smallest value>) in the container.

§Usage

let (values, set_values) = create_signal(vec![1.0, 2.0, 3.0, f32::NAN, 4.0, 5.0]);
let result = use_min::<Vec<f32>, _, _>(values); // Some(1.0)