{"id":13688445,"url":"https://github.com/marc2332/dioxus-query","last_synced_at":"2025-04-13T20:12:16.511Z","repository":{"id":186393094,"uuid":"675112236","full_name":"marc2332/dioxus-query","owner":"marc2332","description":"Fully-typed, async, reusable state management and synchronization for Dioxus 🧬","archived":false,"fork":false,"pushed_at":"2025-04-05T12:22:12.000Z","size":112,"stargazers_count":74,"open_issues_count":10,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T20:12:11.647Z","etag":null,"topics":["async","dioxus","hacktoberfest","rust","state-management"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marc2332.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-05T20:23:23.000Z","updated_at":"2025-04-02T17:18:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"21252d98-0cee-4e09-82a8-241db419d987","html_url":"https://github.com/marc2332/dioxus-query","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.02777777777777779,"last_synced_commit":"5aeaa6a0fd4de01f1c12080a8ec28cdd93d8eeaa"},"previous_names":["marc2332/dioxus-query"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc2332%2Fdioxus-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc2332%2Fdioxus-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc2332%2Fdioxus-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marc2332%2Fdioxus-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marc2332","download_url":"https://codeload.github.com/marc2332/dioxus-query/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248774976,"owners_count":21159534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","dioxus","hacktoberfest","rust","state-management"],"created_at":"2024-08-02T15:01:13.940Z","updated_at":"2025-04-13T20:12:16.492Z","avatar_url":"https://github.com/marc2332.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"[![Discord Server](https://img.shields.io/discord/1015005816094478347.svg?logo=discord\u0026style=flat-square)](https://discord.gg/gwuU8vGRPr)\r\n\r\n# dioxus-query 🦀⚡\r\n\r\n**Fully-typed, async, reusable cached state management** for [Dioxus 🧬](https://dioxuslabs.com/). Inspired by [`TanStack Query`](https://tanstack.com/query/latest/docs/react/overview). \r\n\r\nSee the [Docs](https://docs.rs/dioxus-query/latest/dioxus_query/) or join the [Discord](https://discord.gg/gwuU8vGRPr). \r\n\r\n## Support\r\n\r\n- **Dioxus v0.6** 🧬\r\n- All renderers ([web](https://dioxuslabs.com/learn/0.4/getting_started/wasm), [desktop](https://dioxuslabs.com/learn/0.4/getting_started/desktop), [freya](https://github.com/marc2332/freya), etc)\r\n- Both WASM and native targets\r\n\r\n## Installation\r\n\r\nInstall the latest release:\r\n```bash\r\ncargo add dioxus-query\r\n```\r\n\r\n## Example\r\n\r\n```bash\t\r\ncargo run --example simple\r\n```\r\n\r\n## Usage\r\n\r\n```rust\r\n#[derive(Clone, PartialEq, Eq, Hash)]\r\nenum QueryKey {\r\n    User(usize),\r\n}\r\n\r\n#[derive(Debug)]\r\nenum QueryError {\r\n    UserNotFound(usize),\r\n    Unknown\r\n}\r\n\r\n#[derive(PartialEq, Debug)]\r\nenum QueryValue {\r\n    UserName(String),\r\n}\r\n\r\nasync fn fetch_user(keys: Vec\u003cQueryKey\u003e) -\u003e QueryResult\u003cQueryValue, QueryError\u003e {\r\n    if let Some(QueryKey::User(id)) = keys.first() {\r\n        println!(\"Fetching user {id}\");\r\n        sleep(Duration::from_millis(1000)).await;\r\n        match id {\r\n            0 =\u003e Ok(QueryValue::UserName(\"Marc\".to_string())),\r\n            _ =\u003e Err(QueryError::UserNotFound(*id)),\r\n        }\r\n    } else {\r\n        Err(QueryError::Unknown)\r\n    }\r\n}\r\n\r\n#[allow(non_snake_case)]\r\n#[component]\r\nfn User(id: usize) -\u003e Element {\r\n   let value = use_get_query([QueryKey::User(id)], fetch_user);\r\n\r\n    rsx!( p { \"{value.result().value():?}\" } )\r\n}\r\n\r\nfn app() -\u003e Element {\r\n    let client = use_init_query_client::\u003cQueryValue, QueryError, QueryKey\u003e();\r\n\r\n    let onclick = move |_| {\r\n         client.invalidate_queries(\u0026[QueryKey::User(0)]);\r\n    };\r\n\r\n    rsx!(\r\n        User { id: 0 }\r\n        button { onclick, label { \"Refresh\" } }\r\n    )\r\n}\r\n```\r\n\r\n## Features\r\n- [x] Renderer-agnostic\r\n- [x] Queries and mutations\r\n- [x] Typed Mutations, Query keys, Errors and Values\r\n- [x] Invalidate queries manually\r\n- [x] Invalidate queries when keys change\r\n- [x] Concurrent and batching of queries\r\n- [x] Concurrent mutations\r\n- [ ] Background interval invalidation\r\n- [ ] On window focus invalidation\r\n\r\n\r\n## To Do\r\n- Tests\r\n- Documentation\r\n- Real-world examples\r\n\r\nMIT License\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarc2332%2Fdioxus-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarc2332%2Fdioxus-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarc2332%2Fdioxus-query/lists"}