Skip to content

Commit 6d3f55b

Browse files
Update github pages demo for go 1.12+
- go 1.12 optimizes memory allocation for wasm - see golang/go#27462. This was causing the demo to OOM on memory restricted devices (e.g. phones). - js namespace changed so we need to adapt to that
1 parent 5a35d0e commit 6d3f55b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

etc/gh-pages/_js.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@ func main() {
1616
document := js.Global().Get("document")
1717
in := document.Call("getElementById", "gowen-input")
1818
out := document.Call("getElementById", "gowen-output")
19-
js.Global().Set("gowenRun", js.NewCallback(func([]js.Value) {
19+
js.Global().Set("gowenRun", js.FuncOf(func(js.Value, []js.Value) interface{} {
2020
nodes, err := gowen.Parse(in.Get("value").String())
2121
if err != nil {
2222
out.Set("textContent", fmt.Sprintf("%s", err))
23-
return
23+
return nil
2424
}
2525
results, err := gowen.EvalMultiple(nodes, env)
2626
if err != nil {
2727
out.Set("textContent", fmt.Sprintf("%s", err))
28-
return
28+
return nil
2929
}
3030
s := ""
3131
for _, result := range results {
3232
s += pretty.Sprint(result.ToGo()) + "\n"
3333
}
3434
out.Set("textContent", s)
35+
return nil
3536
}))
3637

3738
<-make(chan struct{}) // stay alive

0 commit comments

Comments
 (0)