You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've followed the basic docs to call an exported function that takes in string/numbers and returns string/numbers but I'm struggling to figure out how to get the JS runtime to await a returned JSPromise from the Swift runtime.
I started with this approach of returning a pointer to the JSPromise:
I'm very new to WASM so I apologize if this is a completely wrong approach, I just needed to get the ball rolling because I can't find anything else online about returning more complex values. I've been trying to understand how its accomplished in Rust but they have fancy annotations from the wasm-bindgen crate which is frankly over my head.
The text was updated successfully, but these errors were encountered:
I think the best approach here would be to have the Swift side define a global value (by using JSObject.global.myLibrary = JSObject.global.Object.create(JSValue.null), for example), then defining properties such as fetch on that (using JSClosure). Then, from the JS side, you’d be able to pull the myLibrary value off of the global after initializing the SwiftWasm instance and call the fetch method.
I've followed the basic docs to call an exported function that takes in string/numbers and returns string/numbers but I'm struggling to figure out how to get the JS runtime to await a returned JSPromise from the Swift runtime.
I started with this approach of returning a pointer to the JSPromise:
But it's obviously not so clear how to deserialize this to an actual
Promise
in JS:I'm very new to WASM so I apologize if this is a completely wrong approach, I just needed to get the ball rolling because I can't find anything else online about returning more complex values. I've been trying to understand how its accomplished in Rust but they have fancy annotations from the wasm-bindgen crate which is frankly over my head.
The text was updated successfully, but these errors were encountered: