[RxJS] Filtering operators: skipWhile and skipUntil
After takeUntil() and takeWhile() function, let's have a look on skipWhile() and skilUntil() functions.
SkipWhile(predicate: function): Skip the value if meet the predicate function.
var foo = Rx.Observable.interval(1000);
/*
--0--1--2--3--4--5--6--7--...
skipWhile(x => x < 3).take(3)
-----------3--4--5|
*/ var bar = foo.skipWhile((x)=>{
return x<3;
}).take(3); bar.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
); /*
"next 3"
"next 4"
"next 5"
"done"
*/
skipUntil(Observable): after 3 seconds, click the start button, to start the foo observalbe.
var foo = Rx.Observable.interval(1000);
var start$ = Rx.Observable.fromEvent(document.querySelector('#start'), 'click');
/*
--0--1--2--3--4--5--6--7--...
skipUntil(start$)
-----------3--4--5|
*/ var bar = foo.skipUntil(start$); bar.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
); /*
"next 3"
"next 4"
"next 5"
"done"
*/
[RxJS] Filtering operators: skipWhile and skipUntil的更多相关文章
- [RxJS] Filtering operators: take, first, skip
There are more operators in the filtering category besides filter(). This lesson will teach how take ...
- [RxJS] Filtering operators: distinct and distinctUntilChanged
Operator distinct() and its variants are an important type of Filtering operator. This lessons shows ...
- [RxJS] Filtering operators: takeLast, last
Operators take(), skip(), and first() all refer to values emitted in the beginning of an Observable ...
- [RxJS] Filtering operators: throttle and throttleTime
Debounce is known to be a rate-limiting operator, but it's not the only one. This lessons introduces ...
- [RxJS] Filtering operators: takeUntil, takeWhile
take(), takeLast(), first(), last(), those opreators all take number or no param. takeUtil and takeW ...
- [RxJS] Transformation operators: debounce and debounceTime
Debounce and debounceTime operators are similar to delayWhen and delay, with the difference that the ...
- [RxJS] Transformation operators: delay and delayWhen
This lessons teaches about delay and delayWhen: simple operators that time shift. delay(number | dat ...
- [RxJS] Creation operators: interval and timer
It is quite common to need an Observable that ticks periodically, for instance every second or every ...
- [RxJS] Creation operators: empty, never, throw
This lesson introduces operators empty(), never(), and throw(), which despite being plain and void o ...
随机推荐
- Android新建项目 默认布局改为 LinearLayout
目前此方法仅适用于eclipse 需要修改SDK 目录 android-sdk/tools/templates/activities/BlankActivity/root/res/layout 文件: ...
- iOS: 学习笔记, 动态添加按钮
1. 新建iOS -> Single View Application. 2. 个性控制器文件YYViewController.m(此处修改为你相应的控制器文件名) // // YYViewCo ...
- 对c++服务端进行覆盖率统计
(1)首先需要为每个被测程序的所有编译文件增加选项,如果文件太多,这无疑是灾难,可利用spec文件达到目的 sed -i '$ a\export LD_PRELOAD=/usr/local/bin/c ...
- windows相关小知识
获得本机MAC1 快捷键win+R打开运行窗口, 输入cmd回车进入控制台2 输入ipconfig -all 找到本地连接中的物理地址 根据IP获得MAC方法:1 进入cmd控制台,执行:ping ...
- 【产品体验】支付宝Alipay9.0
自己摸索中也要学习别人的分析,生命不息,学习不止~~ 支付宝9.0新界面如下图所示——Logo变了,上方突出了“附近”入口,下方新增了“商家”“朋友”两个一级tab,新增了亲情账户,财富界面进行了改 ...
- server-send event object
http://jamie-wang.iteye.com/blog/1849193 event -- onmessage, onopen, onerror 不是方法,而是事件 http://school ...
- 基于android的Socket通信
一.Socket通信简介 Android与服务器的通信方式主要有两种,一是Http通信,一是Socket通信.两者的最大差异在于,http连接使用的是“请求—响应方式”,即在请求时建立连接通道,当客户 ...
- explain简介
EXPLAIN显示了MySQL如何使用索引来处理SELECT语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. 使用方法,在select语句前加上EXPLAIN就可以了: 如: EXPLA ...
- java学习面向对象之异常之一
一.异常的概述: 什么是异常?在我们编写java程序的时候,会出现一些问题,比如内存溢出啊或者数组索引超出最大索引啊,这些编程当中出现的这些个问题就是异常.但是异常也分为可以处理的和不可以处理的.比如 ...
- hadoop2.0安装和配置
hadoop2与hadoop1的配置有些许不同,最主要的是hadoop1里的master变成了yarn 这篇文直接从hadoop的配置开始,因为系统环境和jdk和hadoop1都是一样的. hadoo ...