Skip to content
Permalink
Browse files

rename optimistic to client and document it

  • Loading branch information
nicolodavis committed Jan 14, 2020
1 parent 5823f79 commit 61a45ee5b0fcfa62e33fa0d894fe4553f9687985
Showing with 21 additions and 2 deletions.
  1. +1 −0 docs/documentation/api/Game.md
  2. +18 −0 docs/documentation/secret-state.md
  3. +1 −1 src/core/reducer.js
  4. +1 −1 src/core/reducer.test.js
@@ -19,6 +19,7 @@
move: (G, ctx) => {},
undoable: false, // prevents undoing the move.
redact: true, // prevents the move arguments from showing up in the log.
client: false, // prevents the move from running on the client.
},
},
@@ -69,3 +69,21 @@ const App = Game({
playerView: PlayerView.STRIP_SECRETS
});
```

#### Disabling moves that manipulate secret state on the client

Moves that manipulate secret state often cannot run on the client because
the client doesn't have all the necessary data to process such moves.
These can be marked as server-only by setting `client: false` on move:

```js
moves: {
moveThatUsesSecret: {
move: (G, ctx) => {
...
},
client: false,
}
}
```
@@ -108,7 +108,7 @@ export function CreateGameReducer({ game, multiplayer }) {
}

// Don't run move on client if optimistic = false.
if (multiplayer && move.optimistic === false) {
if (multiplayer && move.client === false) {
return state;
}

@@ -173,7 +173,7 @@ test('disable optimistic updates', () => {
moves: {
A: {
move: () => ({ A: true }),
optimistic: false,
client: false,
},
},
};

0 comments on commit 61a45ee

Please sign in to comment.
You can’t perform that action at this time.