代码之家  ›  专栏  ›  技术社区  ›  Estus Flask

Redux中间件返回值[duplicate]

  •  0
  • Estus Flask  · 技术社区  · 7 年前

    红色指南 suggests 那个 next(action)

    这是 React + Redux example :

    const fooMiddleware = store => next => action => {
      return next({ ...action, foo: 'foo' });
    };
    
    const foobarMiddleware = store => next => action => {
      return next({ ...action, foobar: `${action.foo}bar` });
    };
    
    ...
    
    const store = createStore(
      reducer,
      applyMiddleware(fooMiddleware, foobarMiddleware)
    );
    

    return 中间商。

    1 回复  |  直到 7 年前
        1
  •  2
  •   Gaurav joshi    7 年前

    因为中间件作为 功能 功能 发送 行动 功能 在链中,每个中间件 功能 需要派遣 功能 . 当调用组合函数时,中间件函数接收这些分派函数,而第n个中间件函数接收 store.dispatch 以及随后的每一个 功能

    中间件只是一个带有签名的函数

    storeInstance => 
    functionToCallWithAnActionThatWillSendItToTheNextMiddleware =>
    actionThatDispatchWasCalledWith => 
    valueToUseAsTheReturnValueOfTheDispatchCall