Function leptos_use::use_cycle_list

source ·
pub fn use_cycle_list<T, L>(
    list: L
) -> UseCycleListReturn<T, impl Fn(usize) -> T + Clone, impl Fn() + Clone, impl Fn() + Clone, impl Fn(i64) -> T + Clone>
where T: Clone + PartialEq + 'static, L: Into<MaybeSignal<Vec<T>>>,
Expand description

Cycle through a list of items.

§Demo

Link to Demo

§Usage

use leptos_use::{use_cycle_list, UseCycleListReturn};
let UseCycleListReturn { state, next, prev, .. } = use_cycle_list(
    vec!["Dog", "Cat", "Lizard", "Shark", "Whale", "Dolphin", "Octopus", "Seal"]
);

log!("{}", state.get()); // "Dog"

prev();

log!("{}", state.get()); // "Seal"