DioxusLabs / DioxusLabs/dioxus
Resource / Loader Store
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
Currently there isn't a clean way to async fetch data into a `Store`. It would be convenient if there were counterparts to `Resource` and `Loader` that use `Store`s internally rather than `Signal`s.
## Implement Suggestion
Possibly a new type `LoaderStore`, with `use_loader_store`. `LoaderStore` would be almost identical to `Loader` except internally `real_value` is a `Store>` and `read_value` is a `ReadStore`.
```rs
#[derive(Store)]
struct UserData {
name: String,
}
#[component]
fn List() -> Element {
let users = use_loader_store(move || api::get_user_data())?;
rsx! {
button { onclick: move |_| users.restart(),
"Refresh"
}
for user in users.iter() {
Row { user }
}
}
}
#[component]
fn Row(user: ReadStore) -> Element {
rsx! {
li { "{user.name()}" }
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the existing Resource and Loader implementations, then compare their Signal-based behavior with the Store and ReadStore APIs. The work is done when a LoaderStore and use_loader_store provide async fetching into a Store, support restart, and expose store-backed values for iteration as shown in the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100