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的更多相关文章

  1. [RxJS] Filtering operators: take, first, skip

    There are more operators in the filtering category besides filter(). This lesson will teach how take ...

  2. [RxJS] Filtering operators: distinct and distinctUntilChanged

    Operator distinct() and its variants are an important type of Filtering operator. This lessons shows ...

  3. [RxJS] Filtering operators: takeLast, last

    Operators take(), skip(), and first() all refer to values emitted in the beginning of an Observable ...

  4. [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 ...

  5. [RxJS] Filtering operators: takeUntil, takeWhile

    take(), takeLast(), first(), last(), those opreators all take number or no param. takeUtil and takeW ...

  6. [RxJS] Transformation operators: debounce and debounceTime

    Debounce and debounceTime operators are similar to delayWhen and delay, with the difference that the ...

  7. [RxJS] Transformation operators: delay and delayWhen

    This lessons teaches about delay and delayWhen: simple operators that time shift. delay(number | dat ...

  8. [RxJS] Creation operators: interval and timer

    It is quite common to need an Observable that ticks periodically, for instance every second or every ...

  9. [RxJS] Creation operators: empty, never, throw

    This lesson introduces operators empty(), never(), and throw(), which despite being plain and void o ...

随机推荐

  1. linux下VI编辑器的使用

    一.VI编辑器简述       VI 编辑器是Linux和Unix上最基本的文本编辑器,工作在字符模式下.由于不需要图形界面,使它成了效率很高的文本编辑器.尽管在Linux上也有很多图形界面的编辑器可 ...

  2. vs2015安装没有wim32

    刚开始在官网上下载VS2015没在意太多,选择了默认安装,结果是没有win64的,所以就不能写c代码.默认安装很多库都没有,所以要什么都得下载.转载一篇文章

  3. EFBaseDal

    public class BaseDal<T> where T : class, new()    {        DataModelContainer db = new DataMod ...

  4. SpringMVC源码阅读(二)

    今天分析下ViewResolver和View的实现  下面是ModelAndView的实现 package org.springframework.web.servlet; import java.u ...

  5. LightOj_1030 Discovering Gold

    题目链接 题意: 在一个1 X N 的格子上, 每个格子都有一定的黄金, 你从第一个格子出发, 问到最后一个格子得到黄金的期望. 每次前进使用骰子投点来决定前进步数, 如果投出的点前进后会超过N, 那 ...

  6. Node.js V0.12新特性之性能优化

    v0.12悠长的开发周期(已经过去九个月了,并且还在继续,是有史以来最长的一次)让核心团队和贡献者们有充分的机会对性能做一些优化.本文会介绍其中最值得注意的几个. 支持塞住模式的可写流 现在可写流可以 ...

  7. 【POJ1021】Intervals (最短路解差分约束)

    题目: Sample Input 5 3 7 3 8 10 3 6 8 1 1 3 1 10 11 1 Sample Output 6 题意: 我们选数,每个数只能选一次.给定n个条件[ai,bi]和 ...

  8. 【POJ】2155 Matrix

    二维树状数组. /* poj2155 */ #include <iostream> #include <string> #include <map> #includ ...

  9. 贪心(哈夫曼树):HDU 5884 sort

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA2QAAAKACAIAAAB8KCy/AAAgAElEQVR4nOy9a5Adx3UmWL+kHxuekU ...

  10. [XenServer] XenServer修改IP 以及 root密码

     A.修改IP以及DNS 1. root用户登录console 2.输入命令获得UUID xe pif-list 3.利用UUID查看之前的IP,注意替换下面的1111111111 xe pif-pa ...