redux构成

看了砖家总结的redux实现流程 https://mp.weixin.qq.com/s/idWmfUbPVVqK7Yi0_9NC4A

  • createStore

创建 store 对象,包含 getState, dispatch, subscribe, replaceReducer

  • reducer

reducer 是一个计划函数,接收旧的 state 和 action,生成新的 state

  • action

action 是一个对象,必须包含 type 字段

  • dispatch

dispatch( action ) 触发 action,生成新的 state

  • subscribe

    扫描二维码关注公众号,回复: 11219193 查看本文章

实现订阅功能,每次触发 dispatch 的时候,会执行订阅函数

  • combineReducers

多 reducer 合并成一个 reducer

  • replaceReducer

替换 reducer 函数

  • middleware

扩展 dispatch 函数功能(留出无限丰富的空间)!

猜你喜欢

转载自www.cnblogs.com/yuhanao/p/12911287.html