Fully-typed, async, reusable state management and synchronization for Dioxus 🧬. Inspired by TanStack Query
.
⚠️ Work in progress ⚠️
Compatible with Dioxus v0.4.
bash
cargo add dioxus-query
bash
cargo run --example basic
```rust
enum QueryKeys { User(usize), }
enum QueryError { UserNotFound(usize) }
async fn fetchuser(id: usize) -> QueryResult
fn User(cx: Scope, id: usize) -> Element { to_owned![id];
let value = use_query(cx, move || vec![QueryKeys::User(id)], {
move |_keys| fetch_user(id)
});
render!( p { "{value.result():?}" } )
}
fn app(cx: Scope) -> Element { let client = useprovideclient(cx);
let refresh = |_| client.invalidate_query(QueryKeys::User(0));
render!(
User { id: 0 }
button { onclick: refresh, label { "Refresh" } }
)
} ```
MIT License