Table of Contents

Class ThrottleOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

The throttle/throttleTime operators.

public static class ThrottleOperator
Inheritance
System.Object
ThrottleOperator

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

source Observable<T>

The source observable.

duration TimeSpan

The fixed window length.

scheduler IScheduler

The scheduler to time the window with; defaults to TaskPoolScheduler.

leading bool

Whether to emit the value that opens each window immediately.

trailing bool

Whether 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

T

The 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

source Observable<T>

The source observable.

durationSelector Func<T, Observable<TDuration>>

Given the value that opened the current window, returns the observable whose first emission or completion closes it.

leading bool

Whether to emit the value that opens each window immediately.

trailing bool

Whether 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

T

The element type of the source.

TDuration

The (unused) element type of the duration observable.