Function use_cycle_list

Source
pub fn use_cycle_list<T, L>(
    list: L,
) -> UseCycleListReturn<T, impl Fn(usize) -> T + Clone + Send + Sync, impl Fn() + Clone + Send + Sync, impl Fn() + Clone + Send + Sync, impl Fn(i64) -> T + Clone + Send + Sync>
where T: Clone + PartialEq + Send + Sync + 'static, L: Into<Signal<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"