dotnet / dotnet/reactive

Implement a real throttle (not debounce, like the existing throttle)

Open
#395 29 comments 17 reactions 0 assignees View on GitHub
[area] Rx feature request
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

Currently there is no operator to **ignore elements from an observable sequence that follow a non-ignored element within a specified relative time duration**. This is what would normally be called `Throttle`, while the existing `Throtte` operator is really a debounce operator (see e.g. [The Difference Between Throttling and Debouncing](https://css-tricks.com/the-difference-between-throttling-and-debouncing/)).

Here is a sample implementation of the "real" throttle operator both with and without scheduler:

```c#
public static IObservable AtMostOnceEvery(
this IObservable source,
TimeSpan dueTime)
{
IObservable delay = Observable.Empty().Delay(dueTime);
return source.Take(1).Concat(delay).Repeat();
}

public static IObservable AtMostOnceEvery(
this IObservable source,
TimeSpan dueTime,
IScheduler scheduler)
{
IObservable delay = Observable.Empty().Delay(dueTime, scheduler);
return source.Take(1).Concat(delay).Repeat();
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.