with_static_client_async

Function with_static_client_async 

Source
pub fn with_static_client_async<F, Fut, T>(f: F) -> Promise
where F: FnOnce(Arc<RpcWasmClient>) -> Fut + 'static, Fut: Future<Output = Result<T, String>> + 'static, T: Into<JsValue>,
Expand description

Asynchronously executes a closure with the static RpcWasmClient, returning the result as a JavaScript Promise.

This is the primary way to interact with the static RPC client from exported async functions.

§Parameters

  • f: A closure that receives the Arc<RpcWasmClient> and returns a Future resolving to Result<T, String>, where T: Into<JsValue>.

§Returns

A JS Promise that resolves to T or rejects with an error string.

§Errors

If the static client has not been initialized via init_static_client(), the promise will reject with "RPC client not initialized".