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:

  1. It provides an imperative glue between declarative states.

  2. 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.

A

payload

B

payload

Queue size: 0

demo/index.tsx

Getting started

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.