wasm: add test for js.FuncOf

While there are some browser tests, Node.js is just a lot better for
testing this kind of stuff because it's much faster and we don't need a
browser for this.
This commit is contained in:
Ayke van Laethem
2024-10-18 12:29:28 +02:00
committed by Ron Evans
parent 5e3c816373
commit cd2bb8333d
4 changed files with 72 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
package main
import "syscall/js"
func main() {
js.Global().Call("setCallback", js.FuncOf(func(this js.Value, args []js.Value) any {
println("inside callback! parameters:")
sum := 0
for _, value := range args {
n := value.Int()
println(" parameter:", n)
sum += n
}
return sum
}))
js.Global().Call("callCallback")
}