Skip to main content

promise_async

Function promise_async 

Source
pub fn promise_async<F>(spawner: Option<&SpawnFn>, fut: F) -> Value
where F: Future<Output = Value> + 'static,
Expand description

Wraps an async operation in a background task that resolves a Swan Promise.

Executes fut inside a background task spawned via spawn. Returns immediately with a Value::Promise. Once fut completes, the returned promise resolves to its value.