@laserware/stasis
    Preparing search index...
    • Creates a Redux middleware and connects the Sagas to the Redux Store

      Below we will create a function configureStore which will enhance the Store with a new method runSaga. Then in our main module, we will use the method to start the root Saga of the application.

      configureStore.js

      import createSagaMiddleware from 'redux-saga' import reducer from './path/to/reducer'

      export default function configureStore(initialState) { // Note: passing middleware as the last argument to createStore requires redux@>=3.1.0 const sagaMiddleware = createSagaMiddleware() return { ...createStore(reducer, initialState, applyMiddleware(... other middleware ..., sagaMiddleware)), runSaga: sagaMiddleware.run } }

      main.js

      import configureStore from './configureStore' import rootSaga from './sagas' // ... other imports

      const store = configureStore() store.runSaga(rootSaga)

      Type Parameters

      • C extends object

      Parameters

      • Optionaloptions: SagaMiddlewareOptions<C>

        A list of options to pass to the middleware

      Returns SagaMiddleware<C>