rxjs
rxjs copied to clipboard
fix(debounceTime): handle synchronous schedulers
Description:
Using debounceTime(0, queueScheduler)
was not emitting any values. scheduler.schedule()
emits immediately but logic in debounceTime
was expecting it to always return before emitting.
Related issue (if exists):
Fixes https://github.com/ReactiveX/rxjs/issues/6764
I see the issue.
I think that a cleaner solution would be to create a Subscription
prior to the subscriber.schedule
call, and leverage that, something like:
if (!activeTask) {
subscriber.add(activeTask = new Subscription());
activeTask.add(scheduler.schedule(emitWhenIdle, dueTime));
}
It's perhaps a little more resource intensive per schedule, but it's certainly less complicated.
Let me know if that works out.
That is a nice solution. Can confirm it works and cleans up the scheduler.schedule subscription even after the fact in the synchronous case. Learned a little more about Subscriptions, thanks.
@dancras Apologies on dropping the ball on landing this one. I think there may be another solution here, and we might still try to get this into the 7.x branch.
I've added a commit and moved it over here. I'll try to make sure you get credit for the commits, @dancras
https://github.com/ReactiveX/rxjs/pull/7161