ui: Add goroutine so that blocking is available everywhere

This commit is contained in:
Hajime Hoshi 2016-11-29 01:40:06 +09:00
parent b454ff6547
commit b86f1771e4

View File

@ -96,12 +96,14 @@ func (u *userInterface) loop(g GraphicsContext) error {
ch := make(chan error) ch := make(chan error)
var f func() var f func()
f = func() { f = func() {
if err := u.update(g); err != nil { go func() {
ch <- err if err := u.update(g); err != nil {
close(ch) ch <- err
return close(ch)
} return
js.Global.Get("window").Call("requestAnimationFrame", f) }
js.Global.Get("window").Call("requestAnimationFrame", f)
}()
} }
f() f()
return <-ch return <-ch