DioxusLabs / DioxusLabs/dioxus

Add a way for use_resource to depend on another Resource

Open
#2,627 1 comment 3 reactions 0 assignees View on GitHub
enhancement hooks
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.