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"
*/

最新文章

  1. C#类和接口、虚方法和抽象方法及值类型和引用类型的区别
  2. Xcode中iPhone iPad模拟器调整大小的方法
  3. How to install GSL on linux(ubuntu,centos,redhat)
  4. html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
  5. [POJ 3581]Sequence
  6. EntityFramework Core 2.0 Explicitly Compiled Query(显式编译查询)
  7. oracle空间索引
  8. boost::asio::spawn 将一统C++网络库
  9. SpriteBuilder中粒子发射器的reset on visibility toggle选项解释
  10. 监控MySQL或Web服务是否正常
  11. C++中string跨DLL失败解决途径
  12. 如何通过 Vue+Webpack 来做通用的前端组件化架构设计
  13. Hadoop概念学习系列之再谈hadoop集群里的本地模式、伪分布模式和全分布模式(三十七)
  14. Python入门 ---基础知识
  15. python3 调用 salt-api
  16. 冥想_ PHP抽奖程序概率算法
  17. sqlserver2008debug存储过程
  18. ADS中编译现存项目时常见错误:无法打开文件\…\…\2440init.o的解决办法
  19. Java-web-j2e学习建议路线【转】
  20. Android深入四大组件(六)Service的启动过程

热门文章

  1. SEMAT[软件工程方法和理论 Software Engineering Method and Theory]
  2. 关于UPdate用法的
  3. 2016最新Java笔试题集锦
  4. mongodb常用命令【转】
  5. 下一代hadoop
  6. CodeforcesGym101116 B Bulbs
  7. restful风格,restcontroller与controller
  8. android5.0中RecycleView的用法
  9. 登录MD5加盐处理
  10. IOS7官方推荐图标和图像尺寸