Class SampleOperator
The sample/sampleTime operators.
public static class SampleOperator
- Inheritance
-
System.ObjectSampleOperator
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
sourceObservable<T>The source observable.
periodTimeSpanThe fixed sampling period.
schedulerISchedulerThe 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
TThe 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
sourceObservable<T>The source observable.
notifierObservable<TNotifier>Emits to trigger each sample.
Returns
- Observable<T>
An observable that emits the most recent source value on every notifier tick.
Type Parameters
TThe element type of the source.
TNotifierThe (unused) element type of the notifier.