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. [CSS]overflow内容溢出

      定义和用法 overflow 属性规定当内容溢出元素框时发生的事情. 说明 这个属性定义溢出元素内容区的内容会如何处理.如果值为 scroll,不论是否需要,用户代理都会提供一种滚动机制.因此,有 ...

  2. C对字符串的部分操作

    字符串分割(C++)   经常碰到字符串分割的问题,这里总结下,也方便我以后使用. 一.用strtok函数进行字符串分割 原型: char *strtok(char *str, const char ...

  3. WPF 自定义路由事件

    如何:创建自定义路由事件 首先自定义事件支持事件路由,需要使用 RegisterRoutedEvent 方法注册 RoutedEvent C#语法 public static RoutedEvent ...

  4. iOS中的隐式动画

    隐式动画就是指  在 非 人为在代码中 定义动画  而系统却默认  自带   的动画  叫做隐式动画. 比如  改变 图层  的颜色  位置  和   透明度  的时候    都会  产生附带的渐变的 ...

  5. 【产品体验】支付宝Alipay9.0

    自己摸索中也要学习别人的分析,生命不息,学习不止~~  支付宝9.0新界面如下图所示——Logo变了,上方突出了“附近”入口,下方新增了“商家”“朋友”两个一级tab,新增了亲情账户,财富界面进行了改 ...

  6. bzoj 1034: [ZJOI2008]泡泡堂BNB 貪心

    1034: [ZJOI2008]泡泡堂BNB Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1398  Solved: 727[Submit][Sta ...

  7. Keil C51软件的使用

    进入 Keil C51 后,屏幕如下图所示.几秒钟后出现编辑界 启动Keil C51时的屏幕 进入Keil C51后的编辑界面 简单程序的调试:学习程序设计语言.学习某种程序软件,最好的方法是直接操作 ...

  8. window.alert弹出处理

    # -*- coding:utf-8 -*- """ window.alert 处理 """ from selenium import we ...

  9. leetcode shttps://oj.leetcode.com/problems/surrounded-regions/

    1.从外围搜索O,深度搜索出现了 Line 35: java.lang.StackOverflowError Last executed input: ["OOOOOOOOOOOOOOOOO ...

  10. Alfred(未完待续)

    之前曾经有写过一篇QuickSilver的博文,大力称赞它是Mac下的神器,但是现在,QS光荣下岗了,因为我找到了另外一款比QS更加好用,更加神器的APP:Alfred小帽子. 软件名:Alfred ...