I am having trouble understanding the model for Goroutines within
WebAssembly.

I have a "click" callback with the following form:

        errChan := make(chan error, 1)

        go func() {
                // Call http.PostForm and read response.

                if err != nil {
                        errChan <- err
                        return
                }

                // ...
        }()

        select {
        case err := <-errChan:
                if err != nil {
                        // Handle error.
                }
        case <-time.After(timeout):
                // Handle timeout.
        }

I had expected http.PostForm to proceed, with the timeout expiring only
if http.PostForm took too long. Yet it seems that http.PostForm blocks
until after the timeout expires. Indeed, the http.PostForm call will not
return until the timer expires, no matter what value I set the timer to.

I setup the above callback (named fork) using:

        wasm.AddEventListener(link, "click", js.FuncOf(
                func(this js.Value, args []js.Value) interface{} {
                        return js.FuncOf(fork).Invoke(file)
                }))

Does anyone have any recommended reading for performing HTTP requests
from WebAssembly callbacks?

-- 
Mike

:wq

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20201117083647.GA254219%40imp.flyn.org.

Reply via email to