DioxusLabs / DioxusLabs/dioxus
Add a way for use_resource to depend on another Resource
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
While developing, my app, I wanted to create two different async resources, where one depends on the other. Currently, this can only be (easily) done by converting the second resource to return an option, and defaulting to None while the first resource's future has not resolved yet.
## Implement Suggestion
Add a way for use_resource to depend on another Resource.
This may be done by implementing IntoFuture for Resource, allowing resources to be directly `.await`ed inside other async blocks. This would enable usage like this:
```rs
let resource_1 = use_resource(move || async move { get_something().await });
let resource_2 = use_resource(move || async move { use_resource_1(resource_1.await) });
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.