Skip to content

Instantly share code, notes, and snippets.

@Scarysize
Last active May 6, 2020 05:49
Show Gist options
  • Save Scarysize/66639479cae665bdf65d929945a47236 to your computer and use it in GitHub Desktop.
Save Scarysize/66639479cae665bdf65d929945a47236 to your computer and use it in GitHub Desktop.
import {applyMiddleware, createStore, combineReducers} from 'redux';
import {createSyncMiddleware} from '...somewhere';
export default function initStore(socket) {
let middelware = applyMiddleware(/* redux-logger, thunk etc.*/);
if (/* check if this is the 'leader' */) {
middleware = applyMiddleware(createSyncMiddleware(socket), /* other middlware*/);
}
return createStore(
combineReducers({/* your reducers */}),
middleware
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment