Skip to content

Commit

Permalink
return state as first argument to client.subscribe callback
Browse files Browse the repository at this point in the history
  • Loading branch information
darthfiddler committed Sep 8, 2018
1 parent 64f0125 commit a558092
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions examples/react/modules/threejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class App extends React.Component {

this.client = Client({ game: TicTacToe });

this.client.subscribe(() => {
const { ctx } = this.client.getState();
this.client.subscribe(({ ctx }) => {
if (ctx.gameover) {
this.setState({ gameover: ctx.gameover });
}
Expand Down
5 changes: 3 additions & 2 deletions src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ class _ClientImpl {
}

subscribe(fn) {
this.store.subscribe(fn);
this.transport.subscribe(fn);
const callback = () => fn(this.getState());
this.store.subscribe(callback);
this.transport.subscribe(callback);
}

getState() {
Expand Down

0 comments on commit a558092

Please sign in to comment.