Skip to main content

mutable_state_of

Function mutable_state_of 

Source
pub fn mutable_state_of<T: PartialEq + Send + 'static>(
    value: T,
) -> MutableState<T>
Expand description

A state whose writes of an equal value change nothing. Compose’s mutableStateOf.

ⓘ
let count = remember(|| mutable_state_of(0));
Text(format!("{}", count.get()));
Button("More").on_click(move || count.update(|count| *count += 1));

Made inside remember, the state belongs to that call. Made anywhere else, it is not freed until the program ends.