Difference between audit and debounce in rxjs?

陌路散爱 提交于 2019-12-03 14:49:12

问题


I am reading the offical documentaion of rxjs and then i realized they both are doing exactly same thing.

To me they both seems to exactly similar.

Please someone point out difference between them (if any)


回答1:


I'm going to describe the difference between them in terms of their Time versions as that's how I understand them best.

Both auditTime and debounceTime will initially start a timer when an event comes in. Both will wait the given amount of time before they emit an event. The difference is that debounceTime resets the timer whenever a new event comes in while auditTime does not. auditTime will emit the most recent event after the given number of milliseconds whether or not it is still receiving events. debounceTime will wait for a gap in the events. You said you read the documentation but just to double check I have found this document particularly helpful.




回答2:


Heres a marble diagram to compare the *Time counterparts:

Each value here represents time of its emission.

You can play with this marble diagram here: debounceTime vs throttleTime vs auditTime vs sampleTime

Already having an awesome answer by @qfwfq, I wanted to add a more visual explanation.

Hope this helps someone



来源:https://stackoverflow.com/questions/39184789/difference-between-audit-and-debounce-in-rxjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!