boardgameio / boardgame.io

State Management and Multiplayer Networking for Turn-Based Games
https://boardgame.io
MIT License
10.03k stars 709 forks source link

Client events #360

Open blunket opened 5 years ago

blunket commented 5 years ago

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.

vdfdev commented 5 years ago

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

nicolodavis commented 5 years ago

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.