use std::collections::HashMap; use dioxus_core::prelude::*; use recoil::*; const A_ITEMS: AtomHashMap = |_| HashMap::new(); const B_ITEMS: AtomHashMap = |_| HashMap::new(); const C_SELECTOR: SelectorFamily = |api, key| { let a = api.get(&A_ITEMS.select(&key)); let b = api.get(&B_ITEMS.select(&key)); a + b }; const D_SELECTOR: SelectorFamilyBorrowed = |api, key| -> &i32 { let a = api.get(&A_ITEMS.select(&key)); a }; static App: FC<()> = |ctx| { use_init_recoil_root(ctx, |_| {}); let title = use_read(ctx, &C_SELECTOR); rsx! { in ctx, div { "{title}" // button { onclick: {next_light}, "Next light" } } } }; fn main() { wasm_bindgen_futures::spawn_local(dioxus_web::WebsysRenderer::start(App)) }