1
0
mirror of https://github.com/taigrr/wasm-experiments synced 2025-01-18 04:03:21 -08:00

Add example of getReader bug

This commit is contained in:
Johan Brandhorst 2018-05-13 00:32:35 +01:00
parent 5b0c630b59
commit f6afc46304
No known key found for this signature in database
GPG Key ID: 266C7D9B44EAA057
2 changed files with 27 additions and 0 deletions

7
bug/Makefile Normal file
View File

@ -0,0 +1,7 @@
build: clean compile
clean:
rm -f ../html/test.wasm
compile:
GOOS=js GOARCH=wasm GOROOT=$(GOPATH)/src/github.com/neelance/go/ $(GOPATH)/src/github.com/neelance/go/bin/go build -o ../html/test.wasm main.go

20
bug/main.go Normal file
View File

@ -0,0 +1,20 @@
// +build js,wasm
package main
import (
"syscall/js"
"syscall/js/callback"
)
func main() {
wait := make(chan struct{})
promise := js.Global.Call("fetch", "https://api.github.com")
promise.Call("then", callback.New(func(args []js.Value) {
response := args[0]
r := response.Get("body").Call("getReader")
r.Call("read")
close(wait)
}).Value)
<-wait
}