CombineLatest and withLatestFrom are both AND-style combination operators. In this lesson, we will learn about zip, our last AND-style combinator. It uses the n-th value of each member Observable to produce the n-th output value.

If you zip two observalbe. it will wait both n-th observalbe value emit, and combie them:

  • First of foo + First of bar =  first of output
  • Second of foo + Second of bar = Second of output
  • ...
  • n-th of foo + n-th of bar = n-th of output

It will never combine: n-th of foo + (n+1)-th of bar.

var foo = Rx.Observable.of('h', 'e', 'l', 'l', 'o');
var bar = Rx.Observable.interval(400).take(5); /*
(hello|) (foo)
---0---1---2---3---4| (bar)
zip((x,y) => x)
---h---e---l---l---o|
*/ //var combined = Rx.Observable.zip(foo, bar, (x,y) => x);
var combined = foo.zip(bar, (x,__)=> x); combined.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
); /*
"next h"
"next e"
"next l"
"next l"
"next o"
"done"
*/

[RxJS] Combination operator: zip的更多相关文章

  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: combineLatest

    While merge is an OR-style combination operator, combineLatest is an AND-style combination operator. ...

  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] Transformation operator: repeat

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

  7. [RxJS] Utility operator: do

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

  8. [RxJS] Creation operator: of()

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

  9. [RxJS] Connection operator: multicast and connect

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

随机推荐

  1. 制作font-icon有感

    连日来有些空闲,趁着这闲余时间,我尝试亲自制作一些Font-Icon,让以后可以运用到工作中.但是基于本人水平有限,PS操作只能以非常基础来形容,而AI呢,根本就只会放大操作.在这过程真的非常感谢设计 ...

  2. phpmyadmin数据导入最大限制的解决方法

    mysql导入文件最大限制更改解决方法:phpmyadmin库导入出错:You probably tried to upload too large file. Please refer to doc ...

  3. Oracle数据库常用函数

    Oracle常用函数: 20.COS返回一个给定数字的余弦SQL> select cos(-3.1415927) from dual;COS(-3.1415927)--------------- ...

  4. Xcode-01ARC / Block

    1.nonatomic 2.assign 3.strong 4.weak 5.instancetype 6.@class @property 使部分类在编译时不使用ARC -(可以让这们支持 reta ...

  5. Tomcat,Weblogic,WebSphere,JBoss四种服务器简单对比

    1,tomcat是Servlet容器,支持JSP.Servlet.JDBC等J2EE关键技术,常用于tomcat开发基于数据库.Servlet和JSP页面的Web应用.2,tomcat不是EJB容器, ...

  6. http server v0.1_http_parse.c

    #include <stdio.h> #include <string.h> #include <stdlib.h> #include "mime.h&q ...

  7. BZOI 1507 [NOI2003] Editor

    Background After trying to solve problem EDIT1(Editor) and being ****ed by Brainf**k, Blue Mary deci ...

  8. Contest20140705 testA 二分

    testA 输入文件: testA.in 输出文件testA.out 时限2000ms 问题描述: 有一个城市拥有N个节点,被M条有权无向路径连接.现在你要在一个地方(可以在路径上当然也可以在节点上) ...

  9. vim下如何删除某行之后的所有行

    使用dG进行删除 在命令模式下将光标置于要删除的起始行,然后依次输入d,G

  10. 注意android裁图的Intent action

    现在很多开发者在裁图的时候还是使用com.android.camera.action.CROP 来调用 startActivity(). 这不是个好主意. 任何不是依android开头的Action ...