pub fn use_maybe_sync_memo<R, S>(
    f: impl FnMut() -> R + 'static
) -> ReadOnlySignal<R, S>where
    R: PartialEq,
    S: Storage<SignalData<R>>,
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(cx, || 0);
    let double = use_memo(cx, move || count * 2);
    count += 1;
    assert_eq!(double.value(), count * 2);

    render! { "{double}" }
}