Class DelayWhenOperator
Implements the DelayWhen operator. Mirrors rxjs's delayWhen.
public static class DelayWhenOperator
- Inheritance
-
System.ObjectDelayWhenOperator
Methods
DelayWhen<T, TDuration>(Observable<T>, Func<T, Observable<TDuration>>)
Delays each value from source until the "duration" observable produced for it by
delayDurationSelector emits its first value.
public static Observable<T> DelayWhen<T, TDuration>(this Observable<T> source, Func<T, Observable<TDuration>> delayDurationSelector)
Parameters
sourceObservable<T>The source observable whose values are delayed.
delayDurationSelectorFunc<T, Observable<TDuration>>A function that, given a source value, returns an observable whose first emission signals that the value may now be forwarded.
Returns
- Observable<T>
An observable of the source values, each released once its corresponding duration observable emits.
Type Parameters
TThe element type of the source observable.
TDurationThe element type of the per-value "duration" observable; only used to detect its first emission; the actual value carried is never inspected.
Remarks
Equivalent to the indexed overload with the index ignored. See its remarks for full behavior.
DelayWhen<T, TDuration>(Observable<T>, Func<T, int, Observable<TDuration>>)
Delays each value from source until the "duration" observable produced for it by
delayDurationSelector emits its first value.
public static Observable<T> DelayWhen<T, TDuration>(this Observable<T> source, Func<T, int, Observable<TDuration>> delayDurationSelector)
Parameters
sourceObservable<T>The source observable whose values are delayed.
delayDurationSelectorFunc<T, int, Observable<TDuration>>A function that, given a source value and its index, returns an observable whose first emission signals that the value may now be forwarded.
Returns
- Observable<T>
An observable of the source values, each released once its corresponding duration observable emits.
Type Parameters
TThe element type of the source observable.
TDurationThe element type of the per-value "duration" observable; only used to detect its first emission; the actual value carried is never inspected.
Remarks
delayDurationSelector is called with each source value and its zero-based index; the
duration observable it returns is subscribed to immediately, but only its first emission (via an internal
Take(1)) actually releases the corresponding source value downstream. If a duration observable
completes without ever emitting, the source value it was paired with is silently dropped — it never
reaches the subscriber. Because durations are handled with unbounded concurrency (via MergeMap),
values can be released out of the order their durations were scheduled if a later duration fires before
an earlier one — this operator does not preserve source order the way Delay does. If
delayDurationSelector throws, or a duration observable errors, the error is forwarded
via OnError.