import Reactotron from "reactotron-react-native" ; import { applyMiddleware , compose , createStore , Reducer } from "redux" ; import sagaMiddlewareFactory , { Monitor , SagaIterator } from "redux-saga" ; import Config from "../Config/DebugConfig" ; import ScreenTracking from "./ScreenTrackingMiddleware" ; export default ( rootReducer , rootSaga ) => { const middleware = [ ] ; const enhancers = [ ] ; if ( Config . useReactotron ) { middleware . push ( ScreenTracking ) ; } let opts = { } ; if ( Config . useReactotron ) { const sagaMonitor = Reactotron . createSagaMonitor ( ) ; opts = { sagaMonitor } ; } const sagaMiddleware = sagaMiddlewareFactory ( opts ) ; middleware . push ( sagaMiddleware ) ; enhancers . push ( applyMiddleware ( ... middleware ) ) ; const createAppropriateStore = Config . useReactotron ? Reactotron . createStore : createStore ; const composeEnhancers = window . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose ; const store = createAppropriateStore ( rootReducer , composeEnhancers ( ... enhancers ) ) ; const sagasManager = sagaMiddleware . run ( rootSaga ) ; return { store , sagasManager , sagaMiddleware , } ; } ;