Wraps a user-provided reducer with automatic handling of internal actions:
__HYDRATE__ -- Replaces state wholesale (used for server→client state sync).
__PLAYER_JOINED__ -- Adds a player to state.players.
__PLAYER_LEFT__ -- Marks a player as disconnected in state.players.
__PLAYER_RECONNECTED__ -- Restores a returning player's connection status, preserving all existing data.
__PLAYER_REMOVED__ -- Permanently removes a timed-out disconnected player from state.players.
The wrapped reducer accepts both A (user actions) and InternalAction<S>.
User reducers only need to handle their own action types.
When options.middleware is provided, the middleware stack wraps around the
entire reducer (including internal-action handling). Middleware can observe
all actions flowing through the reducer.
Wraps a user-provided reducer with automatic handling of internal actions:
__HYDRATE__-- Replaces state wholesale (used for server→client state sync).__PLAYER_JOINED__-- Adds a player tostate.players.__PLAYER_LEFT__-- Marks a player as disconnected instate.players.__PLAYER_RECONNECTED__-- Restores a returning player's connection status, preserving all existing data.__PLAYER_REMOVED__-- Permanently removes a timed-out disconnected player fromstate.players.The wrapped reducer accepts both
A(user actions) andInternalAction<S>. User reducers only need to handle their own action types.When
options.middlewareis provided, the middleware stack wraps around the entire reducer (including internal-action handling). Middleware can observe all actions flowing through the reducer.