bgio-effects
The bgio-effects
package provides a structured approach to triggering
ephemeral “effects” from boardgame.io 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.
bgio-effects
helps manage boardgame.io state in two key ways:
-
It provides an imperative glue between declarative states.
-
It can orchestrate how a state transitions over time.
Check out the tutorial for more detail about these two concepts in practice.
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:
emitter.on('explode', () => {
// render explosion/play sound/etc.
});
useEffectListener('explode', () => {
// render explosion/play sound/etc.
}, []);
Demo
Here’s a small example demonstrating a sequence of effects triggered by a single move.
Getting started
-
Read the tutorial to see how adding
bgio-effects
to a boardgame.io game can solve problems in practice. -
Read the game plugin docs for an in-depth guide to configuring the
bgio-effects
game plugin. -
Read the plain JS or React client docs to see how to setup the client extension.
-
Want to try something hands on? Play around with a CodeSandbox of the demo above.
Contributing
This is an experimental project and feedback is welcome. Please open an issue on GitHub 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
bgio-effects
is provided under the terms of
an Anti-Fascist MIT License.