Table of Contents

Class SampleOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

The sample/sampleTime operators.

public static class SampleOperator
Inheritance
System.Object
SampleOperator

Methods

SampleTime<T>(Observable<T>, TimeSpan, IScheduler?)

Sample<T, TNotifier>(Observable<T>, Observable<TNotifier>) sampled by a fixed period instead of a notifier observable. Implemented as a self-rescheduling timer (there is no Observable.Interval creation function yet) rather than layering on Sample<T, TNotifier>(Observable<T>, Observable<TNotifier>).

public static Observable<T> SampleTime<T>(this Observable<T> source, TimeSpan period, IScheduler? scheduler = null)

Parameters

source Observable<T>

The source observable.

period TimeSpan

The fixed sampling period.

scheduler IScheduler

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

Returns

Observable<T>

An observable that emits the most recent source value on every tick of the period.

Type Parameters

T

The element type of the source.

Sample<T, TNotifier>(Observable<T>, Observable<TNotifier>)

Emits the most recent source value whenever notifier emits. A notifier tick with no new source value since the last sample produces no emission. The notifier completing does not complete (or otherwise affect) the result — sampling simply stops happening once it does. Mirrors rxjs's sample.

public static Observable<T> Sample<T, TNotifier>(this Observable<T> source, Observable<TNotifier> notifier)

Parameters

source Observable<T>

The source observable.

notifier Observable<TNotifier>

Emits to trigger each sample.

Returns

Observable<T>

An observable that emits the most recent source value on every notifier tick.

Type Parameters

T

The element type of the source.

TNotifier

The (unused) element type of the notifier.