Skip to content
Discussion options

You must be logged in to vote

Question 1

A move should be pure in the sense that it should rely only on the state provided by its inputs. (It is also OK to rely on some immutable data in scope, but not something stateful that gets mutated.)

I’m not sure I would think of events as side effects exactly. Think of the full state object: { G, ctx, ... }. G is yours. You can do what you want with it. The rest of the state object — ctx, the undo/redo stack, etc. — is managed by boardgame.io and shouldn’t be touched directly. When you dispatch a move on the client, you are actually sending an action to a reducer that operates on this whole state, not just G. The framework would be unhelpful if you couldn’t also update the non-G

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@on3iro
Comment options

Answer selected by on3iro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1051 on January 20, 2022 22:07.