kaoDev/react-ts-sample

View on GitHub
src/store/reduxSagaStore.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { ApplicationState } from 'models/applicationState'
import { reduceApplicationState } from 'reducers/applicationReducer'
import { applyMiddleware, compose, createStore } from 'redux'
import createSagaMiddleware from 'redux-saga'
import { rootSaga } from 'redux/saga/root'

const sagaMiddleware = createSagaMiddleware()

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

export const createApplicationStore = () => {
  const store = createStore<ApplicationState>(
    reduceApplicationState,
    composeEnhancers(applyMiddleware(sagaMiddleware))
  )
  sagaMiddleware.run(rootSaga)

  return store
}