[RxJS] Combination operator: combineLatest
While merge is an OR-style combination operator, combineLatest is an AND-style combination operator. This lesson explains what AND-style combination means, and how you can join values from two or more Observables in a formula.
At the begin, there is no value emit, then bar has value 0, but foo has no value still. Therefore also no value emit, until foo has the first value 0, then output the final value as 0.
var foo = Rx.Observable.interval().take();
var bar = Rx.Observable.interval().take(); /*
----0----1----2----(3|) (foo)
--0--1--2--3--(4|) (bar)
combineLatest((x, y) => x+y)
----01--23-4--(56)-(7|)
*/ var bmi = foo.combineLatest(bar,(x,y) => x+y); // merge: OR
// combineLatest: AND bmi.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
); /*"next 0"
"next 1"
"next 2"
"next 3"
"next 4"
"next 5"
"next 6"
"next 7"
"done"*/
[RxJS] Combination operator: combineLatest的更多相关文章
- [RxJS] Combination operator: withLatestFrom
Operator combineLatest is not the only AND-style combinator. In this lesson we will explore withLate ...
- [RxJS] Combination operator: zip
CombineLatest and withLatestFrom are both AND-style combination operators. In this lesson, we will l ...
- [RxJS] Transformation operator: buffer, bufferCount, bufferTime
This lesson will teach you about another horizontal combination operator: buffer and its variants. B ...
- [RxJS] Transformation operator: scan
All of the combination operators take two or more observables as input. These operators may also be ...
- rxjs自定义operator
rxjs自定义operator
- [RxJS] Utility operator: do
We just saw map which is a transformation operator. There are a couple of categories of operators, s ...
- [RxJS] Creation operator: of()
RxJS is a lot about the so-called "operators". We will learn most of the important operato ...
- [RxJS] Connection operator: multicast and connect
We have seen how Subjects are useful for sharing an execution of an RxJS observable to multiple obse ...
- [RxJS] Transformation operator: repeat
Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...
随机推荐
- AngularJS初体验
最近突然发现,Coding.net真是一个神奇的网站.这各网站90%的请求都是通过ajax完成的.可以发现,不管你点任何链接,网页都不会刷新,点击浏览器的返回或前进按钮也是这样,打开chrome的开发 ...
- Android ART简介
一. Android ART简介 Android DEX/ODEX/OAT文件
- Coursera《machine learning》--(2)单变量线性回归(Linear Regression with One Variable)
本笔记为Coursera在线课程<Machine Learning>中的单变量线性回归章节的笔记. 2.1 模型表示 参考视频: 2 - 1 - Model Representation ...
- C++ 利用socket实现TCP,UDP网络通讯
学习孙鑫老师的vc++深入浅出,有一段时间了,第一次接触socket说实话有点儿看不懂,第一次基本上是看他说一句我写一句完成的,第二次在看SOCKET多少有点儿感觉了,接下来我把利用SOCKET完成T ...
- dispatch队列
GCD编程的核心就是dispatch队列,dispatch block的执行最终都会放进某个队列中去进行,它类似NSOperationQueue但更复杂也更强大,并且可以嵌套使用.所以说,结合bloc ...
- Python写UTF8文件,UE、记事本打开依然乱码的问题
Python写UTF8文件,UE.记事本打开依然乱码的问题 Leave a reply 现象:使用codecs打开文件,写入UTF-8文本,正常无错误.用vim打开正常,但记事本.UE等打开乱码. 原 ...
- android工程混淆和反编译
一.工程文件的混淆 混淆文件下载:http://download.csdn.net/detail/lxq_xsyu/6328751 1.在根目录下添加progard.cfg文件 2.打开project ...
- 精通iOS开发(第5版)
<精通iOS开发(第5版)> 基本信息 原书名:Beginning ios 6 development:exploring the ios sdk 作者: (美)David Mark ...
- What does the number on the visual studio solution icon represent?
The numbers correspond to the internal version numbers of various editions of Visual Studio http://e ...
- WordPress Ultimate Auction插件跨站请求伪造漏洞
漏洞名称: WordPress Ultimate Auction插件跨站请求伪造漏洞 CNNVD编号: CNNVD-201306-396 发布时间: 2013-09-11 更新时间: 2013-09- ...