bgio-effects
v0.7.1
Published
๐ค Helpers for managing state effects in boardgame.io
Downloads
82
Maintainers
Readme
bgio-effects
๐ค 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.
๐พ Installation
npm i bgio-effects
๐ At a glance
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, []);
๐ Documentation
See the full documentation website โ
๐ Contributing
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.
๐ License
The code in this repository is provided under the terms of an Anti-Fascist MIT License.