Hello! I've been running some experiments with WASM support in Go 1.11.
One of the experiments involves compiling a Go library into WASM and then calling it from JS. The post below mentions how to expose Go functions to JS, however, my experiments have shown that calls from JS into Go/WASM are NOT synchronous (which means that setting the return value as a global is not reliable.) The workaround I've implemented involves passing a callback function to the Go/WASM function. The Go/WASM function can then invoke the callback to return values to the caller. This approach allows me to expose the Go/WASM library through a pseudo-synchronous API w/ promises. *Question 1*: are calls from JS into Go/WASM expected to be asynchronous? If so, is the callback passing approach the best way to get return values back to the JS code? *Question 2*: what is the expected overhead of calling from JS into Go? The WASM performance itself is fine (on the order of µs) however the overall performance is quite poor (on the order of ms). Is this expected (or did I just do something stupid ^_^)? The benchmark code can be found here: https://github.com/tsandall/go-js-wasm-benchmark The blog post mentioning how to expose Go functions to JS is here: https://blog.owulveryck.info/2018/06/08/some-notes-about-the-upcoming-webassembly-support-in-go.html#exposing-a-function. This post is linked from the Go wiki. Any help would be appreciated! -Torin -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.