[RxJS] Transformation operators: debounce and debounceTime
Debounce and debounceTime operators are similar to delayWhen and delay, with the difference that they may drop some emissions. This lesson teaches you how debounce works and where is it useful, for instance when building a type-ahead UI.
debounceTime(number): wait for number millionseconds sclience:
var foo = Rx.Observable.interval(100).take(5); /*
--0--1--2--3--4|
debounceTime(1000) // delay
------------------------4|
*/ var result = foo.debounceTime(1000); result.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
); /*
"next 4"
"done"
*/
var foo = Rx.Observable.interval(100).take(5); /*
--0--1--2--3--4|
debounceTime(50) // delay
----0--1--2--3--4|
*/ var result = foo.debounceTime(50); result.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
); /*
"next 0"
"next 1"
"next 2"
"next 3"
"next 4"
"done"
*/
debounce( () => Observable):
var foo = Rx.Observable.interval(100).take(5); /*
--0--1--2--3--4|
debounceTime(1000) // delay
------------------------4|
*/ var result = foo.debounce(() =>
Rx.Observable.interval(1000).take(1)
); result.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
); /*
"next 4"
"done"
*/
[RxJS] Transformation operators: debounce and debounceTime的更多相关文章
- [RxJS] Transformation operators: delay and delayWhen
This lessons teaches about delay and delayWhen: simple operators that time shift. delay(number | dat ...
- [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] Transformation operator: repeat
Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...
- [RxJS] Transformation operator: scan
All of the combination operators take two or more observables as input. These operators may also be ...
- [RxJS] Filtering operators: takeLast, last
Operators take(), skip(), and first() all refer to values emitted in the beginning of an Observable ...
- [RxJS] Filtering operators: take, first, skip
There are more operators in the filtering category besides filter(). This lesson will teach how take ...
- [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 ...
- Rxjs常用operators
本文使用的是angular6内置的rxjs,版本号为6.3.3 concat 通过顺序地发出多个 Observables 的值将它们连接起来,一个接一个的. 参数: 名称 类型 属性 描述 other ...
随机推荐
- 自定义函数中的参数返回值 “-> (Int -> Int)”的问题
func makeIncrementer() -> (Int -> Int) { func addOne(number: Int) -> Int { + number } retur ...
- [我的疑问]String? = "Skiy Chan" 中的问号是什么意思?
var optionalName : String? = "Skiy Chan" String? = "Skiy Chan" 中的问号是什么意思?目前还在看ap ...
- alter system register
alter system register的用法 1 Static Registration via set the listener.ora2 Dynamic Instance Registrati ...
- 2016030201 - github上创建项目
具体步骤如下: 前提是你已经由github账户,登陆你的账户后 步骤1:点击右下角+new repository 2.添加代码库描述内容,比如reposltory name 例如我创建的内容 3.点击 ...
- sizeof()用法
参考:sizeof_百度百科 sizeof()用法汇总(经典) 声明:本文是笔者抽出对自己有用的细节,对前两文的总结. 1.sizeof概念 sizeof是C语言中判断数据类型或者表达式长度符:不是一 ...
- iOS应用如何支持IPV6-b
果然是苹果打个哈欠,iOS行业内就得起一次风暴呀.自从5月初Apple明文规定所有开发者在6月1号以后提交新版本需要支持IPV6-Only的网络,大家便开始热火朝天的研究如何支持IPV6,以及应用中哪 ...
- java子类实例初始化过程
子类的实例化主要分为两个步骤: <1>.类相关静态内容 初始化: *先父类再子类: 1.父类的static属性: 2.父类的static块: 3.子类的static属性: 4 ...
- 打造轻量级自动化测试框架WebZ
一.什么是WebZ WebZ是我用Python写的“关键字驱动”的自动化测试框架,基于WebDriver. 设计该框架的初衷是:用自动化测试让测试人员从一些简单却重复的测试中解放出来.之所以用“关键字 ...
- Netty启动分析
基于Netty-3.2.5 先看一段Netty的服务端代码: import java.net.InetSocketAddress; import java.util.concurrent.Execut ...
- [BZOJ 1053] [HAOI 2007] 反素数ant
题目链接:BZOJ 1053 想一想就会发现,题目让求的 1 到 n 中最大的反素数,其实就是 1 到 n 中因数个数最多的数.(当有多于一个的数的因数个数都为最大值时,取最小的一个) 考虑:对于一个 ...