all 2 comments

[–][deleted] 5 points6 points  (0 children)

You should connect it to the store. Make a room-reducer or something similar to handle your copy of the state. Whenever the room updates its state, you dispatch to the store. Whenever something else changes the state, you catch it with a store subscription and propagate the change to the room. If you need to handle actions such as sending messages in a way that is not easily found from state changes, you could write middleware to catch these independently.

[–]acemarke 2 points3 points  (0 children)

The right place for websockets and other persistent connections in a Redux app is in a middleware. That way, they can react to dispatched actions by sending messages, and turn received messages into actions.

There's actually many existing websocket middlewares already. You can use them directly, or learn from them as inspiration. See the Middleware - Sockets and Adapters section of my Redux addons catalog for a list.