Function freya::prelude::use_maybe_sync_memo
pub fn use_maybe_sync_memo<R, S>(
f: impl FnMut() -> R + 'static
) -> ReadOnlySignal<R, S>
Expand description
Creates a new Selector that may be sync. The selector will be run immediately and whenever any signal it reads changes.
Selectors can be used to efficiently compute derived data from signals.
use dioxus::prelude::*;
use dioxus_signals::*;
fn App() -> Element {
let mut count = use_signal(|| 0);
let double = use_memo(move || count * 2);
count += 1;
assert_eq!(double(), count * 2);
rsx! { "{double}" }
}