[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 ...
随机推荐
- Xcode-程序开发设计-01UIKit 框架
CGRect中的前缀:CoreGraphics.frameworksUIView中的前缀:User InterFace 属于UIKit的框架NS前缀,NS是NextStep 对象方法:辞去第1响应者- ...
- windows server 2012服务器IIS基本配置
- SpringMVC源码阅读(二)
今天分析下ViewResolver和View的实现 下面是ModelAndView的实现 package org.springframework.web.servlet; import java.u ...
- Entity Framework 实践系列 —— 搞好关系 - 单相思(单向一对一,one-to-one)【转】
原以为躲入代码世界,就可以不用搞关系,哪知“关系无处不在”.写代码多年之后,终于明白“面向对象的关键是搞好对象之间的关系”.而Entity Framework作为ORM中的明日之星,首当其冲的使命就是 ...
- matlab的常用快捷键
ctrl+shift+d:控制窗口嵌入还是非嵌入
- eclipse设置字体大小
eclipse是我们常用的开发工具.eclipse中的默认字体往往并不满足我们的需要,我经常要调节一下它的大小或者换一下风格.eclipse中的字体大小怎么改变呢? 工具/原料 eclipse 方法/ ...
- SQL Server 2008 数据库误删除数据的恢复
原文:SQL Server 2008 数据库误删除数据的恢复 原文:http://www.cnblogs.com/dudu/archive/2011/10/15/sql_server_recover_ ...
- Android中关于List与Json转化问题
比如 List<String>list=new ArrayList<String>(); list.add("test1"); list.add(" ...
- python模块与包加载机制
模块的搜索路径: When a module named spam is imported, the interpreter searches for a file named spam.py in ...
- HDU 5929 Basic Data Structure 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Basic Data Structure Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...