aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/wasmfunc.go
blob: 9d0d690e4f554cff1b27453b59bf426e89409cb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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")
}