Difference between audit and debounce in RxJS?

前端 未结 2 1131
面向向阳花
面向向阳花 2021-02-03 21:22

I am reading the official documentation of RxJS and then I realized they both are doing exactly the same thing.

To me they both seem exactly similar.

Please point

2条回答
  •  爱一瞬间的悲伤
    2021-02-03 21:48

    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.

提交回复
热议问题