aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/wasmfunc.go
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/wasmfunc.go')
-rw-r--r--testdata/wasmfunc.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/testdata/wasmfunc.go b/testdata/wasmfunc.go
new file mode 100644
index 000000000..9d0d690e4
--- /dev/null
+++ b/testdata/wasmfunc.go
@@ -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")
+}