Skip to content

Commit

Permalink
Update github pages demo for go 1.12+
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
niklasfasching committed Apr 16, 2019
1 parent 5a35d0e commit 6d3f55b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions etc/gh-pages/_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ func main() {
document := js.Global().Get("document")
in := document.Call("getElementById", "gowen-input")
out := document.Call("getElementById", "gowen-output")
js.Global().Set("gowenRun", js.NewCallback(func([]js.Value) {
js.Global().Set("gowenRun", js.FuncOf(func(js.Value, []js.Value) interface{} {
nodes, err := gowen.Parse(in.Get("value").String())
if err != nil {
out.Set("textContent", fmt.Sprintf("%s", err))
return
return nil
}
results, err := gowen.EvalMultiple(nodes, env)
if err != nil {
out.Set("textContent", fmt.Sprintf("%s", err))
return
return nil
}
s := ""
for _, result := range results {
s += pretty.Sprint(result.ToGo()) + "\n"
}
out.Set("textContent", s)
return nil
}))

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

0 comments on commit 6d3f55b

Please sign in to comment.