[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 you to throttleTime and throttle, which only drop events (without delaying them) to accomplish rate limiting.
- var foo = Rx.Observable.interval(500).take(5);
- /*
- --0--1--2--3--4|
- debounceTime(1000) // waits for silence, then emits
- throttleTime(1000) // first emits, then causes silence
- --0-----2-----4|
- */
- var result = foo.throttleTime(1000);
- result.subscribe(
- function (x) { console.log('next ' + x); },
- function (err) { console.log('error ' + err); },
- function () { console.log('done'); },
- );
throttle( () => Observable):
- var foo = Rx.Observable.interval(500).take(5);
- /*
- --0--1--2--3--4|
- throttle( () => Rx.Observalbe.interval(1000).take(1)) // first emits, then causes silence
- --0-----2-----4|
- */
- var result = foo.throttle( () => Rx.Observable.interval(1000).take(1));
- result.subscribe(
- function (x) { console.log('next ' + x); },
- function (err) { console.log('error ' + err); },
- function () { console.log('done'); },
- );
Result for both:
- /*
- "next 0"
- "next 2"
- "next 4"
- "done"
- */
[RxJS] Filtering operators: throttle and throttleTime的更多相关文章
- [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: skipWhile and skipUntil
After takeUntil() and takeWhile() function, let's have a look on skipWhile() and skilUntil() functio ...
- [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 ...
随机推荐
- AS3.0定义变量的访问范围
在AS3.0中变量的默认访问范围是:internal:包内成员可以访问,包外不可访问.AS2.0默认访问范围是public
- smarty模板引擎原理解析
//php 控制器文件 <?php//引入模板引擎文件include("20130304.php");$smarty =newTinySmarty();$qq_numbers ...
- Android 安全概述
1. 保密: 信息.文档加密.解密 2. 鉴别.认证:就像确认与我们打电话的确实是XXX,而不是骗子 3. 完整性:信息不能被篡改, 4. 不可否认性:确定信息有who产生,并且将来不能否认
- Android 下拉刷新控件Android-PullToRefresh
需要用到一个开源库 Android-PullToRefresh https://github.com/chrisbanes/Android-PullToRefresh ---------------- ...
- WPF后台访问XAML元素
当我们需要从后台访问xaml文件时,我们可以通过这样的方式来操作: private void button1_Click(object sender, RoutedEventArgs e) { Sys ...
- Windows7のping応答の設定
2015年11月13日 18時09分 wanglinqiang整理 ping応答しない場合.ping応答させる.させない等の設定 1.スタート(左下のウィンドウズのロゴ)⇒コントロールパネルを選択. ...
- 区分html与css中的属性
CSS中id与Class的区别 1.在CSS文件里书写时,ID加前缀"#":CLASS用"." 2.id一个页面只可以使用一次:class可以多次引用. 3.I ...
- matlab的cell数组
matlab的cell数组 元胞数组: 元胞数组是MATLAB的一种特殊数据类型,可以将元胞数组看做一种无所不包的通用矩阵,或者叫做广义矩阵.组成元胞数组的元素可以是任何一种数据类型的常数或者常量,每 ...
- wcf纯代码创建控制台应用
https://svn.apache.org/repos/asf/incubator/stonehenge/contrib/stocktrader/dotnet/ stocktrader项目的dotn ...
- 移动存储卡仍然用FAT32文件系统的真相
微软在2001年就为自家的XP系统的本地磁盘默认使用了NTFS文件系统,但是12年之后,市面上的USB可移动设备和SD卡等外置存储器仍然在用着FAT32文件格式,这是什么理由让硬件厂商选择过时的文件系 ...