[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 ...
随机推荐
- 【小结】有关mysql扩展库和mysqli扩展库的crud操作封装
现阶段php如果要操作mysql数据库 php给我们提供了3套库 1.mysql扩展库 面向过程操作 2.mysqli扩展库 面向对象操作和面向过程操作并存 安全性和效率高于mysql扩展库 ...
- Gvim7.4简单配置
今天下午小折腾了一会Gvim编辑器(7.4版,目前最新).看起来高端又没有代码提示,还能锻炼锻炼记忆. 修改了下默认启动配置<修改后如下图>: 打开编辑器: 编辑->启动设定-> ...
- linux 的一些 不常见的指标
1. linux 的理论 最大用户数 2^32 -1 数据来源 linux就是这个范 (没验证) 2. mv 竟然不能修改文件更新时间
- (C语言)char类型与int类型相加
#include <stdio.h> int main(void) { ; ; int c = a + b; a += b; printf("c=%d",c); //p ...
- virtalBox共享文件夹设置
sudo mount -t vboxsf gongxiang /mnt/shared/
- SendMail
public ActionResult SendMail() { MailMessage mss = new MailMessage(); mss.From = new MailAddress(&qu ...
- js将数字转换成大写的人民币表达式
function changeNumMoneyToChinese(money) { var cnNums = new Array("零", "壹", " ...
- windows下端口被占用的解决方法
1:打开CMD输入:netstat -ano | findstr "80" 找到PID: 2:查看应用名称:tasklist | findstr "2544" ...
- 怎么跳出MySQL的10个大坑
淘宝自从2010开始规模使用MySQL,替换了之前商品.交易.用户等原基于IOE方案的核心数据库,目前已部署数千台规模.同时和Oracle, Percona, Mariadb等上游厂商有良好合作,共向 ...
- appFramework在三星某些机型上的兼容问题
有个问题困扰了安卓哥好几天 一个带有fixed抬头的列表页,在向上swipe的时候,有一定概率会把整个画面滚动上去,就连fixed的部分也移动了. 于是哥觉得是webview的问题,找了各种选项,禁用 ...