Skip to content

Commit

Permalink
Guide: added and async fn call example with f64 (#4097)
Browse files Browse the repository at this point in the history
  • Loading branch information
rimutaka authored Sep 7, 2024
1 parent e4f8c45 commit ac8bd2d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion guide/src/reference/js-promises-and-rust-futures.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ must be `JsValue` or no return at all:
```rust
#[wasm_bindgen]
extern "C" {
async fn async_func_1() -> JsValue;
async fn async_func_1_ret_number() -> JsValue;
async fn async_func_2();
}

async fn get_from_js() -> f64 {
async_func_1_ret_number().await.as_f64().unwrap_or(0.0)
}
```

The `async` can be combined with the `catch` attribute to manage errors from the
Expand Down

0 comments on commit ac8bd2d

Please sign in to comment.