ghostgril

请教一下, redux 的 compose 这种用法是做什么的?

  •  
  •   ghostgril · Apr 13, 2018 · 2308 views
    This topic created in 2969 days ago, the information mentioned may be changed or developed.

    有这样一句代码

    const finalCreateStore = compose(applyMiddleware(thunk), devtools.instrument())(createStore)
    

    最好的一个括号里面的 createStore 是什么意思呢? createStore 是创建 store 的方法,但是为何要写在这里呢

    3 replies    2018-04-17 11:46:35 +08:00
    ghostgril
        1
    ghostgril  
    OP
       Apr 13, 2018
    compose 我是知道他是返回一个依次执行参数里面的方法的函数
    Neilllllllllll
        2
    Neilllllllllll  
       Apr 17, 2018
    compose() 内部实现大概是(...args) => f(g(h(...args)))这个样子的
    Neilllllllllll
        3
    Neilllllllllll  
       Apr 17, 2018
    @Neilllllllllll 返回的是增强过的 createStore 函数下面生成 store
    const store = finalCreateStore(rootReducer);
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2742 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 06:47 · PVG 14:47 · LAX 23:47 · JFK 02:47
    ♥ Do have faith in what you're doing.