Skip to content

Commit e082c3e

Browse files
committed
chore: Use Composition APIs in the webgl example
1 parent d083b69 commit e082c3e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/examples/components/webgl_component.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99
"time"
1010

11+
composition "github.com/rfwlab/rfw/v1/composition"
1112
core "github.com/rfwlab/rfw/v1/core"
1213
dom "github.com/rfwlab/rfw/v1/dom"
1314
events "github.com/rfwlab/rfw/v1/events"
@@ -47,11 +48,11 @@ var (
4748
)
4849

4950
// NewWebGLComponent returns a component demonstrating WebGL via a snake game.
50-
func NewWebGLComponent() *core.HTMLComponent {
51-
c := core.NewComponent("WebGLComponent", webglComponentTpl, nil)
52-
dom.RegisterHandlerFunc("webglStart", func() { startGame() })
53-
dom.RegisterHandlerFunc("webglFullscreen", fullscreen)
54-
return c
51+
func NewWebGLComponent() *composition.Component {
52+
cmp := composition.Wrap(core.NewComponent("WebGLComponent", webglComponentTpl, nil))
53+
cmp.On("webglStart", startGame)
54+
cmp.On("webglFullscreen", fullscreen)
55+
return cmp
5556
}
5657

5758
func init() {

0 commit comments

Comments
 (0)