Redux provides a convenient helper for combining many reducers called combineReducer, but it focuses in on specific attributes on our state, making it incompatible with using the State ADT. We would like a way to avoid keeping all of our reducers in a single file and want the ability to still combine them in a manner that works with the State ADT.

So we will put together our own helper that we also call combineReducers, but explore how we can use the First Monoid and mreduceMap to get us all the power that the Redux helper provides, but setup for our unique needs. As a bonus we will get a sneak peak of the power of using the flipcombinator to create easy to read compositions without pesky argument juggling

// combineReducers :: [ Reducer ] -> Reducer
/*
export const combineReducers = reducers => action =>
mreduceMap(First, applyTo(action), reducers);
*/
// We take reducers first and action second, but we use action first, reducers second.
// It is good case to use flip
/*
export const combineReducers = flip(action =>
mreduceMap(First, applyTo(action))
);*/ // We can use compose to remove action param, applyTo will get action
// Then the return result will be passed into mreduceMap(First)
export const combineReducers = flip(
compose(
mreduceMap(First),
applyTo
)
);

最新文章

  1. RedHat Enterprise Linux 6.4 使用 Centos 6 的yum(转)
  2. jQuery对象与DOM对象之间的转换方法
  3. javascript中的链表结构—从链表中删除元素
  4. ce游戏内存修改器(Cheat Engine)
  5. 关于 ‘--exec’ 参数( find 命令)及介绍 ‘xargs ’命令区别(新版)
  6. CocoaPods 使用手册
  7. Android 应用开发性能优化完全分析
  8. Bzoj 2243: [SDOI2011]染色 树链剖分,LCT,动态树
  9. poj2007
  10. openresty nginx 安装过程记录
  11. hibou 主界面自己侧滑的定义
  12. 【Cocos2d-X游戏实战开发】捕鱼达人之单例对象的设计(二)
  13. USACO 3.3 Shopping Offers
  14. 15 Validation
  15. [Swift-2019力扣杯春季决赛]2. 按字典序排列最小的等效字符串
  16. SQL Sever 2008 R2版本添加Northwin数据库错误解决
  17. AHOI2019N省联考凉凉记
  18. java 面试题2
  19. java io系列12之 BufferedInputStream(缓冲输入流)的认知、源码和示例
  20. PTA寒假三

热门文章

  1. bzoj1597 斜率优化dp
  2. Power BI连接至Amazon Redshift
  3. 转:Filter的执行顺序与实例
  4. 浮生半日:探究Python字节码
  5. Python的zip函数(转)
  6. 【BZOJ 1998】 1998: [Hnoi2010]Fsk物品调度(双向链表+并查集+置换)
  7. Line Reflection -- LeetCode
  8. 输入sql语句,将结果写入到xml文件
  9. Atom | 编辑器Atom的使用小结
  10. python 实现简单的KNN算法