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. time返回当前的 Unix 时间戳而$_SERVER["REQUEST_TIME"]得到请求开始时的时间戳

    time():返回当前的 Unix 时间戳 $_SERVER["REQUEST_TIME"]:得到请求开始时的时间戳,可以用来判断完成整个php处理的时间

  2. Dictionary通过Value找到它的key

    private void GetDicKeyByValue() { Dictionary<string, string> dic = new Dictionary<string, s ...

  3. Ubuntu启动错误Checking Battery State的处理

    一.问题描述 二.处理方法 方法一: 按下 ctrl + alt + F1,进入终端,使用管理员权限执行下列代码 sudo rm /etc/X11/xorg.conf sudo reboot 方法二: ...

  4. SignalR介绍与Asp.net,前台即时通信【转】

    SignalR 是一个asp.net异步库,它提供广播消息到多个client端的机制. SignalR能用来持久客户端与服务端的连接,让我们便于开发一些实时的应用,例如聊天室在线预订系统,股票交易等实 ...

  5. ZOOKEEPER在CENTOS6上的再安装

    作DUBBO时,肯定是需要的,,对的,,DUBBO也要熟悉一下才行啦.. URL: http://www.centoscn.com/CentosServer/test/2015/0120/4531.h ...

  6. Hibernate 注解多对一 要求在多那边产生一个外键而不会另外产生一个表

    在使用hibernate注解的时候,我们映射一对多时,有时候莫名其妙的产生了两张表,其中一张表是A_B,这并不符合数据库中多的一方放置一个外键的原则,那么如何控制只产生一个表呢,请看下面的例子: 多的 ...

  7. 【HDU3948】 The Number of Palindromes (后缀数组+RMQ)

    The Number of Palindromes Problem Description Now, you are given a string S. We want to know how man ...

  8. Java中类Exchaner浅析

    Exchaner用于实现两个人之间的数据交换,每个人在完成一定的事物后想与对方交换数据,第一个先拿出数据的人将一直等待第二个人拿着数据到来时,才能彼此交换数据. 张孝祥老师在讲解Exchaner时的比 ...

  9. ServiceStack.Redis常用操作 - 事务、并发锁

    一.事务 使用IRedisClient执行事务示例: using (IRedisClient RClient = prcm.GetClient()) { RClient.Add("key&q ...

  10. 登录MD5加盐处理

    一:解决方案资源管理器截图: 二:operatorDAL.cs代码 using System; using System.Collections.Generic; using System.Linq; ...