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)
var f func()
f = func() {
if err := u.update(g); err != nil {
ch <- err
close(ch)
return
}
js.Global.Get("window").Call("requestAnimationFrame", f)
go func() {
if err := u.update(g); err != nil {
ch <- err
close(ch)
return
}
js.Global.Get("window").Call("requestAnimationFrame", f)
}()
}
f()
return <-ch