itaylor/redux-socket.io

Asynchronously loaded client script

Closed this issue · 2 comments

Hi there. First I would like say thank you for great plugin.

I like the concept of createSocketIoMiddleware, but would like to load socket.io client lib and initialise socket connection only when user visits some specific part of an SPA.

So it is not possible to initialise createSocketIoMiddleware in advance, because io library is not present yet. Do you have any suggestion how to handle this situation? Thanks

I think you could use the same thing that I suggested here:
#13 (comment)

Basically, you'd put a proxy middleware in the Redux middleware chain that passes through all actions until you've initialized socket.io. Once you've initialized socket.io, you'd let it start calling though to the middleware you created with createSocketIoMiddleware.

You're the third person to ask for something like this, maybe I should write some tests for it and add it to the Readme.md and make it the "official" way to solve this case.

Sorry for the duplicate. Usually I use search, but yesterday I've been out of my mind as even issue title doesn't make sense to me today. Anyway thanks @itaylor. Closing this.