pub fn use_selector_with_dependencies<R: PartialEq, D: Dependency>(
    cx: &ScopeState,
    dependencies: D,
    f: impl FnMut(D::Out) -> R + 'static
) -> ReadOnlySignal<R>where
    D::Out: 'static,
Expand description

Creates a new Selector with some local dependencies. The selector will be run immediately and whenever any signal it reads or any dependencies it tracks changes

Selectors can be used to efficiently compute derived data from signals.

use dioxus::prelude::*;
use dioxus_signals::*;

fn App(cx: Scope) -> Element {
    let mut local_state = use_state(cx, || 0);
    let double = use_selector_with_dependencies(cx, (local_state.get(),), move |(local_state,)| local_state * 2);
    local_state.set(1);
  
    render! { "{double}" }
}