mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
6e12f287b0
commit
be665a3526
@ -208,16 +208,17 @@ func (u *userInterface) loop(g GraphicsContext) error {
|
|||||||
var cf js.Callback
|
var cf js.Callback
|
||||||
f = func([]js.Value) {
|
f = func([]js.Value) {
|
||||||
if err := u.update(g); err != nil {
|
if err := u.update(g); err != nil {
|
||||||
go func() {
|
|
||||||
ch <- err
|
ch <- err
|
||||||
close(ch)
|
close(ch)
|
||||||
}()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
js.Global.Get("window").Call("requestAnimationFrame", cf)
|
js.Global.Get("window").Call("requestAnimationFrame", cf)
|
||||||
}
|
}
|
||||||
cf = js.NewCallback(f)
|
cf = js.NewCallback(f)
|
||||||
|
// Call f asyncly to be async since ch is used in f.
|
||||||
|
go func() {
|
||||||
f(nil)
|
f(nil)
|
||||||
|
}()
|
||||||
return <-ch
|
return <-ch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user