Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow
Created April 10, 2017 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LazyFatArrow/9d49d514b2157411171b2ef4e56edb40 to your computer and use it in GitHub Desktop.
Save LazyFatArrow/9d49d514b2157411171b2ef4e56edb40 to your computer and use it in GitHub Desktop.
import createSagaMiddleware from 'redux-saga';
import { reactReduxFirebase } from 'react-redux-firebase';
import {
createStore,
applyMiddleware,
compose
} from 'redux';
// root reducer
import rootReducer from './rootReducer';
// redux devtools
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
// root saga
import rootSaga from './rootSaga';
// Firebase config
var config = {
apiKey: <YOUR_API_KEY>,
authDomain: <YOUR_AUTH_DOMAIN>,
databaseURL: <YOUR_DATABASE_URL>,
projectId: <YOUR_PROJECT ID>,
storageBucket: <YOUR_STORAGE_BUCKET>,
};
// create the store
const sagaMiddleware = createSagaMiddleware();
const configureStore = () => {
const store = {
...createStore(rootReducer, composeEnhancers(
applyMiddleware(sagaMiddleware), reactReduxFirebase(config, {
userProfile: 'users', // where profiles are stored in database
profileFactory: (userData) => { // how profiles are stored in database
return {
name: userData.displayName,
points: 0,
}
}
})))
};
sagaMiddleware.run(rootSaga);
return store;
};
export default configureStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment