Skip to main content

jspi_block_on_promise

Function jspi_block_on_promise 

Source
pub fn jspi_block_on_promise(promise: &Promise) -> Result<JsValue, JsValue>
👎Deprecated:

JSPI support is experimental and subject to change; jspi_block_on_promise requires a runtime with WebAssembly JS Promise Integration enabled

Expand description

Suspend the current JSPI execution until promise settles, returning the resolved value as Ok or the rejection reason as Err — without blocking the event loop, and without an async call chain.

May only be called where a WebAssembly.promising frame is on the stack: within a #[wasm_bindgen(jspi)] export, or a task spawned (transitively) from a JSPI context. Calling it elsewhere throws a SuspendError at runtime.

Promises are eager, so concurrency composes at the promise level: start several JS calls, then suspend on each or on a Promise::all / Promise::race combination. A Rust Future is awaited by suspending on its completion promise: jspi_block_on_promise(&future_to_promise(fut)).