Skip to content

Instantly share code, notes, and snippets.

@mitu217
Created February 16, 2017 09:50
Show Gist options
  • Save mitu217/82f4a083743a0fbeb6fbf5b54f6bad98 to your computer and use it in GitHub Desktop.
Save mitu217/82f4a083743a0fbeb6fbf5b54f6bad98 to your computer and use it in GitHub Desktop.
React + Redux + Redux-saga
import { takeEvery, delay } from 'redux-saga';
import { put, call } from 'redux-saga/effects';
import { increment } from './actions';
export function* incrementAsync() {
yield call(delay, 1000);
yield put(increment());
}
export default function* rootSaga() {
yield* takeEvery('increment', incrementAsync);
}
import { createStore, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import rootReducer from './reducers';
import saga from './sagas';
export default function configureStore(initialState) {
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
rootReducer,
initialState,
applyMiddleware(
sagaMiddleware,
)
);
sagaMiddleware.run(saga);
return store;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment