internal/hooks: Rename Update -> BeforeUpdate

This commit is contained in:
Hajime Hoshi 2018-03-15 02:50:10 +09:00
parent e085f511ec
commit 1b0e71765f
4 changed files with 9 additions and 9 deletions

View File

@ -166,7 +166,7 @@ var (
)
func init() {
hooks.AppendHookOnUpdate(func() error {
hooks.AppendHookOnBeforeUpdate(func() error {
var err error
theContextLock.Lock()
if theContext != nil {

View File

@ -88,7 +88,7 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
c.offscreen.fill(0, 0, 0, 0)
setRunningSlowly(i < updateCount-1)
if err := hooks.Run(); err != nil {
if err := hooks.RunBeforeUpdateHooks(); err != nil {
return err
}
if err := c.f(c.offscreen); err != nil {

View File

@ -54,7 +54,7 @@ var theInputState = &inputState{
}
func init() {
hooks.AppendHookOnUpdate(func() error {
hooks.AppendHookOnBeforeUpdate(func() error {
theInputState.update()
return nil
})

View File

@ -14,16 +14,16 @@
package hooks
var onUpdateHooks = []func() error{}
var onBeforeUpdateHooks = []func() error{}
// AppendHookOnUpdate appends a hook function that is run before the main update function
// AppendHookOnBeforeUpdate appends a hook function that is run before the main update function
// every frame.
func AppendHookOnUpdate(f func() error) {
onUpdateHooks = append(onUpdateHooks, f)
func AppendHookOnBeforeUpdate(f func() error) {
onBeforeUpdateHooks = append(onBeforeUpdateHooks, f)
}
func Run() error {
for _, f := range onUpdateHooks {
func RunBeforeUpdateHooks() error {
for _, f := range onBeforeUpdateHooks {
if err := f(); err != nil {
return err
}