working go wasm bridge

This commit is contained in:
vedhavyas committed 2019-08-07 12:47:59 +02:00
1 parent d528eeada8
commit 5a771cc80d
5 files changed
+133 -29

No files matched your search

+8 -3
View File
@@ -7,12 +7,17 @@ import (
"syscall/js"
)
func printWasm(v []js.Value) {
func printWasm(this js.Value, v []js.Value) interface{} {
fmt.Println("Hello from WASM", v)
return nil
}
func main() {
js.Global().Set("printWasm", js.NewCallback(printWasm))
c := make(chan struct{}, 0)
fmt.Println("WASM Go Initialized")
// register functions
js.Global().Set("printWasm", js.FuncOf(printWasm))
fmt.Println("Done...")
<-make(chan struct{})
<-c
}
Binary file not shown.