📤 Helpers for managing state effects in boardgame.io.
This package provides a structured approach to triggering ephemeral “effects” in game code that can be consumed from state on the client. It provides a game plugin and a client-side extension that emits events for your effects.
npm i bgio-effects
Call effects from your moves or other game code:
function move(G, ctx) {
ctx.effects.explode();
}
Listen for effects on the client:
const onExplode = () => {
// render explosion/play sound/etc.
};
// With the plain JS emitter
emitter.on('explode', onExplode);
// With the React hook
useEffectListener('explode', onExplode, []);
See the full documentation website →
This is an experimental project and feedback is welcome. Please open an issue if you run into any problems, have a question, or want to suggest features/improvements. PRs are welcome too 😊.
Please also note the code of conduct and be kind to each other.
The code in this repository is provided under the terms of an Anti-Fascist MIT License.