-
When toying around with a remote master, I noticed that the callback passed to the subscribe method is called twice on the client that made a move (suggesting that there were two state changes), while it is only called once on the other clients. At first I thought this was because the client runs the game in parallel, and the optimistic update causes a local state change - resulting in an additional invocation of the callback. But adding It would be greatly appreciated if someone could shine some light on this issue. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Your intuition is correct. Even with |
Beta Was this translation helpful? Give feedback.
-
Thanks for clearing that up! While it does not really seem intuitive to me, it's good to know that that's the intended behaviour. |
Beta Was this translation helpful? Give feedback.
Your intuition is correct. Even with
client: false
the client itself still runs some logic, at least as far as to discover that move is disabled on the client. Then — even if the state hasn’t changed — it calls the subscriber callbacks. So, as you suspected, the client making the move has its callbacks called twice: once from the local “optimistic” update (even if it didn’t actually produce a state change), and then again when the remote update arrives.