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), Unknown }
enum QueryValue { UserName(String), }
fn fetchuser(keys: &[QueryKeys]) -> BoxFuture
fn User(cx: Scope, id: usize) -> Element { let value = usequery(cx, move || vec![QueryKeys::User(*id)], fetchuser);
render!( p { "{value.result().value():?}" } )
}
fn app(cx: Scope) -> Element {
let client = useprovidequery_client::
let refresh = |_| {
to_owned![client];
cx.spawn(async move {
client.invalidate_query(QueryKeys::User(0)).await;
});
};
render!(
User { id: 0 }
button { onclick: refresh, label { "Refresh" } }
)
} ```
MIT License