Table of Contents

Class WithLatestFromOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Extension methods implementing the withLatestFrom operator.

public static class WithLatestFromOperator
Inheritance
System.Object
WithLatestFromOperator

Methods

WithLatestFrom<T>(Observable<T>, params Observable<T>[])

Combines each value emitted by source with the latest value from every observable in others, as a list (source value first, then each other's latest value in order), only when source itself emits. Same-type-only for now (unlike rxjs's heterogeneously-typed tuple overloads), mirroring how Zip<T>(params Observable<T>[])/CombineLatest<T>(params Observable<T>[]) handle multiple same-type sources.

public static Observable<IReadOnlyList<T>> WithLatestFrom<T>(this Observable<T> source, params Observable<T>[] others)

Parameters

source Observable<T>

The primary source sequence, driving each output emission.

others Observable<T>[]

The observables whose latest values are combined with each source emission, in order.

Returns

Observable<IReadOnlyList<T>>

An observable of lists — [sourceValue, others[0]'s latest, others[1]'s latest, ...] — one per source emission once every observable in others has emitted at least once.

Type Parameters

T

The element type shared by source and every observable in others.

Remarks

No output is produced until every observable in others has emitted at least once. Each is subscribed to before source, so synchronous ones already have a latest value by the time source's first (possibly also synchronous) emission arrives. Any of them completing has no effect on the output — its last known value keeps being used. If any observable errors, the error is forwarded via OnError. The output completes when source completes, regardless of others.

WithLatestFrom<TSource, TOther>(Observable<TSource>, Observable<TOther>)

Combines each value emitted by source with the latest value from other as a tuple, only when source itself emits.

public static Observable<(TSource Source, TOther Other)> WithLatestFrom<TSource, TOther>(this Observable<TSource> source, Observable<TOther> other)

Parameters

source Observable<TSource>

The primary source sequence, driving each output emission.

other Observable<TOther>

The observable whose latest value is combined with each source emission.

Returns

Observable<(TSource Source, TOther Other)>

An observable of (Source, Other) tuples, one per source emission once other has emitted at least once.

Type Parameters

TSource

The type of values emitted by source.

TOther

The type of values emitted by other.

Remarks

Equivalent to the overload taking a resultSelector, using tuple construction as the selector. See its remarks for full behavior.

WithLatestFrom<TSource, TOther, TResult>(Observable<TSource>, Observable<TOther>, Func<TSource, TOther, TResult>)

Combines each value emitted by source with the latest value from other via resultSelector, only when source itself emits — other emitting on its own never produces an output value.

public static Observable<TResult> WithLatestFrom<TSource, TOther, TResult>(this Observable<TSource> source, Observable<TOther> other, Func<TSource, TOther, TResult> resultSelector)

Parameters

source Observable<TSource>

The primary source sequence, driving each output emission.

other Observable<TOther>

The observable whose latest value is combined with each source emission.

resultSelector Func<TSource, TOther, TResult>

A function combining a source value with the latest other value.

Returns

Observable<TResult>

An observable of the combined values, one per source emission once other has emitted at least once.

Type Parameters

TSource

The type of values emitted by source.

TOther

The type of values emitted by other.

TResult

The type of values produced by resultSelector.

Remarks

No output is produced until other has emitted at least once. other is subscribed to before source, so a synchronous other already has a latest value by the time source's first (possibly also synchronous) emission arrives. other completing has no effect on the output — its last known value keeps being used. If resultSelector throws, or either observable errors, the error is forwarded via OnError. The output completes when source completes, regardless of other.