itaylor / redux-socket.io

An opinionated connector between socket.io and redux
410 stars 53 forks source link

Async middleware loading #12

Closed anaibol closed 8 years ago

anaibol commented 8 years ago

Hi, I am working on an universal/isomorphic redux app and loading socket.io after the rest of the app is loaded, on componentDidMount. Having issues for using this middleware before socket.io is loaded, I was asking me for your example: isn't slow to wait for socket.io beeing loaded to create the redux store with the middlewares?

Thanks for sharing this!

itaylor commented 8 years ago

Going back and re-reading this issue, I think it might be that you're wanting the same thing as #13, where he was wanting a way to wait to initialize redux-socket.io middleware until after something else has happened in your app.

However, if you're just concerned about the spin-up time of socket.io, you probably don't need to be. The overhead to call something like let socket = io('http://localhost:3000') is minimal, as that call does not block or wait for the socket to be established, it just starts the websocket connection process and creates the socket object. It's not until the connect event is emitted that the socket is actually connected.