Redux Saga Recipes
Example
import { applyMiddleware, compose, createStore } from 'redux'
import { browserHistory } from 'react-router'
import makeRootReducer from './reducers'
import createSagaMiddleware from 'redux-saga'
import firebase from 'firebase/app';
import 'firebase/database';
const firebaseConfig = {}
const reduxFirebase = {
userProfile: 'users',
enableLogging: 'false'
}
firebase.initializeApp(firebaseConfig);
function* helloSaga() {
try {
yield firebase.ref('/some/path').push({ nice: 'work!' })
} catch(err) {
console.log('Error in saga!:', err)
}
}
export default (initialState = {}, history) => {
const sagaMiddleware = createSagaMiddleware()
const middleware = [ sagaMiddleware ]
const store = createStore(
makeRootReducer(),
{},
compose(
applyMiddleware(...middleware)
)
)
return store
}
sagaMiddleware.run(helloSaga)