Skip to content

Commit b8b54f0

Browse files
committed
fix sample
1 parent 7b29422 commit b8b54f0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

samples/custom-event/custom-event.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ function init() {
1414
victory = false
1515
time = 0
1616

17-
// run a callback every time that event is triggered
18-
// the `listen()` returns a function to unlisten your event
19-
const unlistenThisEvent = listen('player-moved', (x, y) => {
17+
// run a callback every time that "player-moved" event is triggered
18+
listen('player-moved', function onPlayerMoved(x, y) {
2019
console.log(`player moved to (${x}, ${y})`)
2120
if (x > finishLineX) {
2221
victory = true
2322
time = T
2423
player.color = 2
25-
// run until collision happens
26-
unlistenThisEvent()
24+
25+
// use `unlisten()` to remove um event listener callback
26+
unlisten('player-moved', onPlayerMoved)
2727
}
2828
})
2929

@@ -32,7 +32,7 @@ function init() {
3232
// do something
3333
})
3434

35-
// or after
35+
// or after an event
3636
listen('after:player-moved', (x, y) => {
3737
// do something
3838
})

0 commit comments

Comments
 (0)