[Recompose] Merge RxJS Button Event Streams to Build a React Counter Component
Combining input streams then using scan to track the results is a common scenario when coding with streams. This lesson walks you through setting up two buttons and merging their input events together to build a streaming Counter component.
const CounterStream = componentFromStream(
props$ => { const { stream: onInc$, handler: onInc } = createEventHandler();
const { stream: onDec$, handler: onDec } = createEventHandler(); return props$
.switchMap(
propos => Observable.merge(
onInc$.mapTo(1),
onDec$.mapTo(-1)
)
.startWith(propos.value)
.scan((acc, curr) => acc + curr)
.map((value) => ({ value, onInc, onDec })))
.map(
Counter
)
}
);
[Recompose] Merge RxJS Button Event Streams to Build a React Counter Component的更多相关文章
- [RxJS] Handling Multiple Streams with Merge
You often need to handle multiple user interactions set to different streams. This lesson shows hows ...
- [RxJS] Refactoring Composable Streams in RxJS, switchMap()
Refactoring streams in RxJS is mostly moving pieces of smaller streams around. This lessons demonstr ...
- button JS篇ant Design of react之二
最近更新有点慢,更新慢的原因最近在看 <css世界>这本书,感觉很不错 <JavaScript高级程序设计> 这本书已经看了很多遍了,主要是复习前端的基础知识,基础知识经常会过 ...
- button JS篇ant Design of react
这篇看ant Desgin of react的button按钮的js代码,js代码部分是typescript+react写的. button组件里面引用了哪些组件: import * as React ...
- [React Native] Build a Github Repositories component
Nav to Repos component from Dashboard.js: goToRepos(){ api.getRepos(this.props.userInfo.login) .then ...
- [React Native] Build a Separator UI component
In this lesson we'll create a reusable React Native separator component which manages it's own style ...
- [MDX] Build a Custom Provider Component for MDX Deck
MDX Deck is a great library for building slides using Markdown and JSX. Creating a custom Providerco ...
- [Poi] Customize Babel to Build a React App with Poi
Developing React with Poi is as easy as adding the babel-preset-react-appto a .babelrc and installin ...
- [Recompose] Compose Streams of React Props with Recompose’s compose and RxJS
Functions created with mapPropsStream canned be composed together to build up powerful streams. Brin ...
随机推荐
- css让背景颜色与背景图片同时显示
background:url(../images/bg02.png) #25282e left top no-repeat;
- iOS开发者中心重置设备列表
苹果开发者账号允许的测试设备为100台,如果你注册了,这台机器就算是一个名额,禁用也算一个名额,仍被计入机器总数,每年可以重置一次,那我们怎么重置机器数量呢? 我们需要给苹果发送申请: https:/ ...
- 解决js计算 小数加减乘除失真的功能函数
function floatPoint(one,two,str){ //转化为字符串 one = ''+one two = ''+two //切割成整数部分和小数部分 var oneStr = one ...
- 【Henu ACM Round#24 D】Iterated Linear Function
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把B提取出来就是一个等比数列了. 求和一下会发现是这种形式. \(B*\frac{(A^n-1)}{A-1}+A^n*x\) 则求一 ...
- C/C++中相对路径与绝对路径以及斜杠与反斜杠的区别
1 绝对路径与相对路径 绝对路径表示相对容易得多,依次将文件所在盘符文件夹逐级展开就是绝对路径: ofstream infile("E:\\MyDoc\\file.txt", io ...
- 一个leetcode解题报告类目,代码很简洁
http://bookshadow.com/leetcode/ 里面的代码很简洁.可以看.
- 转:iOS app支付宝接口调用的一点总结(补充支付宝SDK&Demo下载地址)
iosiOSIOS文档服务器测试电话 由于app内需要用到支付功能,选择了当前最流行的支付宝进行支付.在进行内嵌支付宝功能开发时,被它狠狠的耍了一把. 根据支付宝开发文档,参考demo代码.将相关支付 ...
- 大海教你学手游2015CocosLua第一季_00课程介绍
话说大盘从5100直掉到3500点,千仅仅股票跌幅超过20%,跌跌不休.散户.证监会.做空机构開始斗气地主来了: 散户:叫地主 空头:抢地主,3分 证监会:pass 空头:压死 证监会:不要 散户:不 ...
- 基于深度学习的病毒检测技术无需沙箱环境,直接将样本文件转换为二维图片,进而应用改造后的卷积神经网络 Inception V4 进行训练和检测
话题 3: 基于深度学习的二进制恶意样本检测 分享主题:全球正在经历一场由科技驱动的数字化转型,传统技术已经不能适应病毒数量飞速增长的发展态势.而基于沙箱的检测方案无法满足 APT 攻击的检测需求,也 ...
- [转]Python UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 的解决办法
UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 的解决办法 python在安装时,默认的编码是ascii,当 ...