组合redux thunk和redux批处理操作的正确方法是什么?

组合redux thunk和redux批处理操作的正确方法是什么?,redux,redux-thunk,redux-batched-actions,Redux,Redux Thunk,Redux Batched Actions,将redux批处理操作插入现有redux存储的正确方法是什么?我完全被Redux中间件API弄糊涂了 目前我正在使用redux-thunk和redux-little-router 以下是创建我的Redux存储的代码源: import { createStore, applyMiddleware, compose, combineReducers } from 'redux' import thunk from 'redux-thunk' import { routerForBrowser } f

redux批处理操作
插入现有redux存储的正确方法是什么?我完全被Redux中间件API弄糊涂了

目前我正在使用
redux-thunk
redux-little-router

以下是创建我的Redux存储的代码源:

import { createStore, applyMiddleware, compose, combineReducers } from 'redux'
import thunk from 'redux-thunk'
import { routerForBrowser } from 'redux-little-router'
import reducers from './store'
import routes from './routes'

const { reducer, middleware, enhancer } = routerForBrowser({ routes })

// Combine all reducers and instantiate the app-wide store instance
const allReducers = combineReducers({ ...reducers, router: reducer })

// Build middleware (if devTools is installed, connect to it)
const allEnhancers = (window.__REDUX_DEVTOOLS_EXTENSION__
  ? compose(
      enhancer,
      applyMiddleware(thunk, middleware),
      window.__REDUX_DEVTOOLS_EXTENSION__())
  : compose(
      enhancer,
      applyMiddleware(thunk, middleware)))

// Instantiate the app-wide store instance
const initialState = window.initialReduxState
const store = createStore(
  allReducers,
  initialState,
  allEnhancers
)

公开了两种用法:
启用批处理
批调度中间件
。在我的案例中,我应该使用哪一个?

在我回到令人难以置信的redux源代码、redux thunk、redux批处理操作

正确的方法似乎是使用
batchDispatchMiddleware
,如下所示:

import { batchDispatchMiddleware } from 'redux-batched-actions'

// ...

const allEnhancers = (window.__REDUX_DEVTOOLS_EXTENSION__
  ? compose(
      enhancer,
      applyMiddleware(batchDispatchMiddleware, thunk, middleware),
      window.__REDUX_DEVTOOLS_EXTENSION__())
  : compose(
      enhancer,
      applyMiddleware(batchDispatchMiddleware, thunk, middleware)))
注意:我不知道我是否可以发送批量thunks。我在当前的应用程序中没有这样做。使用风险自负