I'm a little confused by the documentation how I would go about using this for a socket event instead of a fetch request.
For example, I am using socket.io and have setup a special channel called 'getInitialState' to hydrate the initialState from the server. I'm also using socketIoMiddleware for dispatching actions to the server.
The following code doesnt seem to ever resolve even though I have verified the server is emitting the initialState object.
const reducer = asyncInitialState.outerReducer(combineReducers({
...rootReducer,
asyncInitialState: asyncInitialState.innerReducer,
}))
socket.emit('getInitialState')
const loadStore = () => {
return new Promise(resolve => {
socket.on('getInitialState', (initialState) => resolve(initialState))
})
}
const storeCreator = applyMiddleware(
asyncInitialState.middleware(loadStore),
socketIoMiddleware(socket)
)
const store = storeCreator(reducer)
I'm a little confused by the documentation how I would go about using this for a socket event instead of a fetch request.
For example, I am using socket.io and have setup a special channel called 'getInitialState' to hydrate the initialState from the server. I'm also using socketIoMiddleware for dispatching actions to the server.
The following code doesnt seem to ever resolve even though I have verified the server is emitting the initialState object.