Rxjs: `debounceTime` emit right away when they reach the end of the observable they are debouncing

Created on 24 Mar 2019  路  3Comments  路  Source: ReactiveX/rxjs

Bug Report

Current Behavior
debounce and debounceTime emit right away when they reach the end of the observable they are debouncing as described in https://stackoverflow.com/a/55248103/5692151. This behavior is not described in the doc https://rxjs-dev.firebaseapp.com/api/operators/debounceTime

Reproduction

  • REPL or Repo link:
    (https://rxviz.com/v/1o7AgWPJ)

Expected behavior
If I understand correctly what the doc says, the observable should be emiited after a duration dueTime but not immediately.

Environment

  • Runtime: Chrome 72
  • RxJS version: Rxjs 6.2.1
docs

Most helpful comment

Yeah, if it's the expected behaviour, it should be mentioned in the docs.

Also, I guess it could be argued that it should be delayed in some circumstances. If the source emits a value shortly after an already-debounced value has been emitted from the operator, there are situations in which the subscriber could receive two notifications that are separated by an interval less than the specified duration.

All 3 comments

IMO, this isn't a bug and is reasonable behaviour. The point of denouncing is to ensure notifications are not emitted too quickly. If the source completes, there will be no further notifications, so emitting the last notification right away is justifiable. I see no reason to wait out the delay.

Hello @cartant
If so, won't it be nice to mention such behavior in the doc? :) It's not really obvious.

Yeah, if it's the expected behaviour, it should be mentioned in the docs.

Also, I guess it could be argued that it should be delayed in some circumstances. If the source emits a value shortly after an already-debounced value has been emitted from the operator, there are situations in which the subscriber could receive two notifications that are separated by an interval less than the specified duration.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benlesh picture benlesh  路  3Comments

cartant picture cartant  路  3Comments

Agraphie picture Agraphie  路  3Comments

cartant picture cartant  路  3Comments

chalin picture chalin  路  4Comments