bevyengine / bevyengine/bevy

Async TaskPool with Http Request Example Wanted

Open
#6,903 26 comments 9 reactions 0 assignees View on GitHub
A-Tasks C-Examples O-Web
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## How can Bevy's documentation be improved?
I'm suggesting something that may be incorrect! But it seems that an async IoTaskPool example would be ideal for helping teach people how to bring in/send out external data to/from a webserver. This would be in the case where using sockets would be overkill.

As far as I understand the main example documentation around IoTaskPool is the test within this lib.rs. (which for myself, a bevy and rust noob, was too sparse).
https://github.com/bevyengine/bevy/blob/main/crates/bevy_core/src/lib.rs#L145

Also the AsyncComputeTaskPool example is too specific to be useful for understanding channels/http requests. https://github.com/bevyengine/bevy/blob/main/examples/async_tasks/async_compute.rs

It would be nice to see an example where the bevy app calls out to a webserver using some sort of user input, and then the webserver returns data that is rendered in the bevy game. Using something like reqwest (if applicable). I believe channels would also be needed for this example? This would really paint the full picture on how to currently handle these sort of network io tasks for a bevy game. I'm guessing many more people interested in WASM bevy development would be able to utilize this example.

Ohh did I mention the motivation for this example is for WASM targets? :)

### Example
I have managed to create a PoC for this, but it's quite barbaric and I'm guessing someone could make a really slick example of this idea and put it up as an official example.
https://gist.github.com/miketwenty1/baa1634fe558186e606c02932b8f37c8

Also note, this seems to work fine with either `IoTaskPool` or `AsyncComputeTaskPool` So I'm sort of just guessing IoTaskPool is more appropriate in this case.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.