boardgame.io icon indicating copy to clipboard operation
boardgame.io copied to clipboard

Client events

Open blunket opened this issue 6 years ago • 2 comments

I'd like to be able to access onTurnEnd from the client side, so I can play a chime/bell sound to notify the user of their turn.

Other events on the client would be good too.

blunket avatar Feb 10 '19 02:02 blunket

You can use an enhancer.

See these examples:

https://github.com/nicolodavis/boardgame.io/blob/master/docs/debugging.md

https://github.com/freeboardgame/FreeBoardGame.org/blob/master/src/games/seabattle/sound.ts

vdfdev avatar Feb 10 '19 03:02 vdfdev

Yes, that should work.

The only downside is that you're depending on an internal implementation detail (for example, if we pull out Redux and use another state management library beneath the hood your code will break). I think we'll eventually want some way to register callbacks with the client that are invoked when certain events happen.

nicolodavis avatar Feb 11 '19 06:02 nicolodavis