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的更多相关文章

  1. [RxJS] Combination operator: withLatestFrom

    Operator combineLatest is not the only AND-style combinator. In this lesson we will explore withLate ...

  2. [RxJS] Combination operator: zip

    CombineLatest and withLatestFrom are both AND-style combination operators. In this lesson, we will l ...

  3. [RxJS] Transformation operator: buffer, bufferCount, bufferTime

    This lesson will teach you about another horizontal combination operator: buffer and its variants. B ...

  4. [RxJS] Transformation operator: scan

    All of the combination operators take two or more observables as input. These operators may also be ...

  5. rxjs自定义operator

    rxjs自定义operator

  6. [RxJS] Utility operator: do

    We just saw map which is a transformation operator. There are a couple of categories of operators, s ...

  7. [RxJS] Creation operator: of()

    RxJS is a lot about the so-called "operators". We will learn most of the important operato ...

  8. [RxJS] Connection operator: multicast and connect

    We have seen how Subjects are useful for sharing an execution of an RxJS observable to multiple obse ...

  9. [RxJS] Transformation operator: repeat

    Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...

随机推荐

  1. __set($key,$values) 和__get($varName) 魔术方法设置读取私有属性

    __set($key,$val) 对类内私有属性赋值 作用:对私有属性的处理 当在类外对类内的私有属性赋值时会自动调用此函数 __get($varName) 读取类内私有属性 作用:虽然可以外部访问, ...

  2. supervisor进程管理

    install :  apt-get install supervisor crete  a  xxxx.conf  file at   /etc/supervisor/conf.d the cont ...

  3. Django国际化注意事项

    涉及两部分内容: py/html文件国际化.外部js文件国际化 步骤 1. settings.py 激活相应的配置 2. 针对py文件,需要注意被翻译代码的编写方式 3. 针对html文件,需要注意被 ...

  4. rust尝鲜

    官网 http://www.rust-lang.org/ 下载链接 http://static.rust-lang.org/dist/rust-0.10-i686-unknown-linux-gnu. ...

  5. struts中如何将前台的值能在action中获取到

    如何获取值----三种方式(属性驱动,对象驱动,模型驱动)  A:属性驱动 必须生成get,set方法  B:对象驱动 给对象也必须生成get,set方法  c模型驱动 模型驱动需要action去实现 ...

  6. 修炼debug

    常用方法: alert console.log 行号手工打breakpoints 手工加入debugger:配合条件if(){debugger;} break on dom modify eventL ...

  7. 利用IKVM在C#中调Java程序

    原文转自:http://luanxiyuan.iteye.com/blog/1937081 IKVM.NET是一个针对Mono和微软.net框架的java实现,其设计目的是在.NET平台上运行java ...

  8. keil采用C语言模块化编程时全局变量、结构体的定义、声明以及头文件包含的处理方法

    以前写单片机程序时总是把所用函数和变量都写在一个c文件里,后来遇到大点的项目,程序动则几千行,这种方式无疑会带来N多麻烦,相信大家都有所体验吧! 后来学会了在keil里进行模块化编程,即只把功能相同或 ...

  9. Android中关于List与Json转化问题

    比如 List<String>list=new ArrayList<String>(); list.add("test1"); list.add(" ...

  10. Oracle 字符集的查看和修改 -转

    一.什么是Oracle字符集 Oracle字符集是一个字节数据的解释的符号集合,有大小之分,有相互的包容关系.ORACLE 支持国家语言的体系结构允许你使用本地化语言来存储,处理,检索数据.它使数据库 ...