[RxJS] Combination operator: zip
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的更多相关文章
- [RxJS] Combination operator: withLatestFrom
Operator combineLatest is not the only AND-style combinator. In this lesson we will explore withLate ...
- [RxJS] Combination operator: combineLatest
While merge is an OR-style combination operator, combineLatest is an AND-style combination operator. ...
- [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] Transformation operator: repeat
Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...
- [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 ...
随机推荐
- CENTOS elasticsearch plugin install:Failed: SSLException[java.security.ProviderException,解决
安装Elasticsearch插件时总报SSLException yum upgrade nss 解决
- ASP.NET MVC轻教程 Step By Step 9——分页
现在我们要把Index视图的留言信息进行分页显示. Step 1. 创建路由 我们希望以类似地址http://localhost:41583/Page1来表示第一页,Page2表示第二页,以此类推.在 ...
- Quartz1.8.5例子(六)
/* * Copyright 2005 - 2009 Terracotta, Inc. * * Licensed under the Apache License, Version 2.0 (the ...
- LightOj_1342 Aladdin and the Magical Sticks
题目链接 题意: 地上有n种棍子, 其中有两种类型, 一种类型是可识别, 一种类型是不可识别, 每个棍子都有一个权值. 当你捡到可识别的, 那么你以后就不会再捡这个棍子, 如果是不可识别的, 那么你有 ...
- The Derivation About CNN and Antoencoder
The Derivation About CNN and Antoencoder 公式推导 本人用latex写的关于CNN和autoencoder的推导,前向和反向传播的推导都有证明.pdf下载地址T ...
- 又拍云——图像处理师(GraphicsMagick、ImageMagick、FFmpeg)
云处理平台开发工程师 工作地:杭州 岗位职责:负责云处理平台研发工作: 岗位要求: 扎实的 C 语言编程基础及算法优化能力: 至少能够熟练使用一门脚本语言(Python.Ruby.Lua 等)进行日常 ...
- [SQL Server]一次执行资料夹内的.sql 指令码
原文:[SQL Server]一次执行资料夹内的.sql 指令码 初始资料库时,我们Developers们会准备很多.sql指令码来建立资料表.检视甚至初始资料,那麽要怎麽一次执行资料夹内的*.sql ...
- Android程序安装后在模拟器上不显示,并且控制台显示The launch will only sync the application package on the device!
初学安卓,今天写了一个小例子,可是eclipse控制台却提示 No Launcher activity found! The launch will only sync the application ...
- Android网络框架Volley(体验篇)
Volley是Google I/O 2013推出的网络通信库,在volley推出之前我们一般会选择比较成熟的第三方网络通信库,如: android-async-http retrofit okhttp ...
- poj1150
这道题告诉我们递推一定要慢慢细细的推Pmn=n!/m!,我们可以先考虑n!的最后一位是什么首先最后一位非0位我们首先想到把0都干掉也就是先把2和5提出来,这两个其实是同样的方法对于N!中有多少个因数2 ...