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

  1. [RxJS] Transformation operators: delay and delayWhen

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

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

  3. [RxJS] Transformation operator: repeat

    Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...

  4. [RxJS] Transformation operator: scan

    All of the combination operators take two or more observables as input. These operators may also be ...

  5. [RxJS] Filtering operators: takeLast, last

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

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

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

  7. [RxJS] Creation operators: interval and timer

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

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

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

  9. Rxjs常用operators

    本文使用的是angular6内置的rxjs,版本号为6.3.3 concat 通过顺序地发出多个 Observables 的值将它们连接起来,一个接一个的. 参数: 名称 类型 属性 描述 other ...

随机推荐

  1. RHEL 7特性说明(六):集群

    来自:Linux中国  2014-07-16 00:00:00  ed Hat Enterprise Linux 7.0 是 Red Hat 的下一代操作系统完整套件,旨在用于关键任务企业级计算以及顶 ...

  2. 从一个模板函数聊聊模板函数里面如何获得T的名字

    写了个小程序,遇到点问题.总结总结,学习学习 #include<vector> #include<iostream> #include<typeinfo> usin ...

  3. Xcode-01ARC / Block

    1.nonatomic 2.assign 3.strong 4.weak 5.instancetype 6.@class @property 使部分类在编译时不使用ARC -(可以让这们支持 reta ...

  4. 学习总结之Log4NET

    通过在网上查找了一些资料,用了些时间学习了log4NET,做了一个小小的总结,说一下它的特点吧 首先呢log4NET是.Net下一个非常优秀的开源日志记录组件.它可以将日志分成不同等级,也可以按照我们 ...

  5. 写了几天的博客-feel

    写博客 真的总结我自己的知识.长见识了.记录下自己遇到的东西,算是一个总结,有问题了,还可以回头看一下.很好 真的很好.

  6. C# 下载资源

    //创建一个初始化请求对象 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("http://wwww.b ...

  7. 十大响应式Web设计框架

    http://www.csdn.net/article/2014-05-13/2819739-responsive-frameworks-for-web-design 对于设计师而言,网站设计中的任意 ...

  8. [BZOJ - 2631] tree 【LCT】

    题目链接:BZOJ - 2631 题目分析 LCT,像线段树区间乘,区间加那样打标记. 这道题我调了一下午. 提交之后TLE了,我一直以为是写错了导致了死循环. 于是一直在排查错误.直到.. 直到我看 ...

  9. 串口传输文件 lrzsz

    假设有一种开发环境,一块板子,除了串口,没有任何外部出入输出设备,没有sd卡,没有网线,这个时候如果你想跟这块板子传输交互文件,要怎么办? 根据modem所采用的文件传输协议:xmodem,ymode ...

  10. Delphi中WideString类型如何转化成String类型

    var wstr:WideString; str:string; begin str:=WideCharToString(PWideChar(wstr)); end;