https://github.com/bevyengine/web-task
A task executor for wasm
https://github.com/bevyengine/web-task
Last synced: 23 days ago
JSON representation
A task executor for wasm
- Host: GitHub
- URL: https://github.com/bevyengine/web-task
- Owner: bevyengine
- License: apache-2.0
- Created: 2025-09-23T03:22:36.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2026-03-30T13:52:13.000Z (29 days ago)
- Last Synced: 2026-04-03T20:38:12.649Z (24 days ago)
- Language: Rust
- Size: 26.4 KB
- Stars: 8
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
This crate is a modern alternative to `web-bindgen-futures` built around `async-task`.
# Pros & Cons
**Pros:**
+ Provides both `spawn` (for `Send` futures) and `spawn_local` (for `!Send` futures).
+ `spawn` and `spawn_local` return `Task` futures, which resolve to return values.
+ It's possible to cancel futures using task handles.
+ Non-send futures (which are common on web) can have send task-handles.
**Cons:**
+ Some older browser versions are not supported.
# Platform Support
This crate only supports the `wasm32-unknown-unknown` target, and makes use of various browser-specific APIs.
Enabling the `+atomics` nightly target feature automatically enables a thread-safe runtime, which works with web-workers but which may have different performance characteristics.
# Testing
This crate supports headless-browser testing using `wasm-bindgen-test`. To run the test-suite, install `wasm-pack` and run the following, substitution `` for `--chrome`, `--firefox`, or `--safari` as desired.
```ignore
wasm-pack test --headless
```
To test the thread-safe backend, use the nightly toolchain, and uncomment the build instruction in `.cargo/config.toml`.