[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 ...
随机推荐
- 桂电在线-转变成bootstrap版
由于angularjs的不熟悉,而且SEO需要学习更多东西,于是先采用bootstrap版本,毕竟工作上也需要使用bootstrap,然后参照视频教程学习. bootstrap 基本模板 <!D ...
- 轻松使用px为单位开发移动端页面
研究移动端页面已经有许久了,一直执着于rem来开发,不谈性能怎么样,单从工作效率上看影响了不少,首先要固定设计稿的宽度,一般都是固定在640px,然后在根据根目录的字体大小来计算出每个元素的rem的值 ...
- prepare—Article【准备篇】之SSH_tool#PuTTY
第一:下载PuTTY: url : http://www.openssh.com/ 下载界面: 安装后: 详解以上命令 ① ② PuTTYgen is a key generator. It ...
- [转载]为什么使用%lf读取double型的值,而用%f进行显示?
博客地址:http://blog.csdn.net/shenzhou111/article/details/7826444 今天看到一篇好文章,mark一下. 出去旅游了一下,所以有些天没敲代码,于是 ...
- css3实现钟表特效
<!doctype html><html><head><meta http-equiv="Content-Type" content=&q ...
- window—BAT脚本
bat脚本注释方法: 1.:: 注释内容(第一个冒号后也可以跟任何一个非字母数字的字符) 2.rem 注释内容(不能出现重定向符号和管道符号) 3.echo 注释内容(不能出现重定向符号和管道符号)〉 ...
- bzoj 3632: 外太空旅行 最大团
3632: 外太空旅行 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 389 Solved: 129[Submit][Status] Descript ...
- NEURAL NETWORKS, PART 2: THE NEURON
NEURAL NETWORKS, PART 2: THE NEURON A neuron is a very basic classifier. It takes a number of input ...
- 在linux中使用php将word文档转为pdf
使用本教程需要在linux中安装openoffice,改页面中有详细的安装与使用教程(http://www.cnblogs.com/sustudy/p/3999628.html). 既然,你看了该教程 ...
- h.264并行解码算法分析
并行算法类型可以分为两类 Function-level Decomposition,按照功能模块进行并行 Data-level Decomposition,按照数据划分进行并行 Function-le ...