Class ThrottleOperator
The throttle/throttleTime operators.
public static class ThrottleOperator
- Inheritance
-
System.ObjectThrottleOperator
Methods
ThrottleTime<T>(Observable<T>, TimeSpan, IScheduler?, bool, bool)
Throttle<T, TDuration>(Observable<T>, Func<T, Observable<TDuration>>, bool, bool) with a fixed TimeSpan window instead of a per-value
duration selector. Built on top of Throttle<T, TDuration>(Observable<T>, Func<T, Observable<TDuration>>, bool, bool) using Timer(TimeSpan, IScheduler?) —
safe to reuse (unlike Delay, see its own remarks) because only one duration subscription is ever
active at a time, so there is no concurrent-timer ordering hazard.
public static Observable<T> ThrottleTime<T>(this Observable<T> source, TimeSpan duration, IScheduler? scheduler = null, bool leading = true, bool trailing = false)
Parameters
sourceObservable<T>The source observable.
durationTimeSpanThe fixed window length.
schedulerISchedulerThe scheduler to time the window with; defaults to TaskPoolScheduler.
leadingboolWhether to emit the value that opens each window immediately.
trailingboolWhether to emit the most recent value seen during a window once it closes.
Returns
- Observable<T>
An observable that throttles emissions per the leading/trailing configuration.
Type Parameters
TThe element type of the source.
Throttle<T, TDuration>(Observable<T>, Func<T, Observable<TDuration>>, bool, bool)
Emits a value, then ignores subsequent values for a "duration" window opened by
durationSelector(that value). Matches rxjs's default config
(leading: true, trailing: false):
the leading edge of each window is emitted immediately and the trailing edge is dropped. Passing
trailing: true additionally emits the most recent value seen during the
window once it closes. Mirrors rxjs's throttle.
public static Observable<T> Throttle<T, TDuration>(this Observable<T> source, Func<T, Observable<TDuration>> durationSelector, bool leading = true, bool trailing = false)
Parameters
sourceObservable<T>The source observable.
durationSelectorFunc<T, Observable<TDuration>>Given the value that opened the current window, returns the observable whose first emission or completion closes it.
leadingboolWhether to emit the value that opens each window immediately.
trailingboolWhether to emit the most recent value seen during a window once it closes.
Returns
- Observable<T>
An observable that throttles emissions per the leading/trailing configuration.
Type Parameters
TThe element type of the source.
TDurationThe (unused) element type of the duration observable.