main-loop-async 0.1.2

Makes running async code from a main loop (ui loop, game loop) more ergonomic
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use wasm_bindgen_test::wasm_bindgen_test;
use wasm_bindgen_test::wasm_bindgen_test_configure;

wasm_bindgen_test_configure!(run_in_browser);
fn main() {
    #[wasm_bindgen_test]
    async fn test_for_deadlock() -> Result<(), Box<dyn std::error::Error>> {
        let rx = main_loop_async::spawn_with_return(async || 200);

        let task_result = rx.await?; //If we can't block the calling task use try_recv instead
        assert_eq!(task_result, 200, "we expect the value we sent in");
        Ok(())
    }
}