Skip to content

,System.IObservable{--1},System.Func{--0,--1,--2})}

Observable.WithLatestFrom(IObservable, IObservable, Func) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

public static IObservable<TResult> WithLatestFrom<TFirst, TSecond, TResult>(this IObservable<TFirst> first, IObservable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)

Summary: Merges two observable sequences into one observable sequence by combining each element from the first source with the latest element from the second source, if any. Starting from Rx.NET 4.0, this will subscribe to second before subscribing to first to have a latest element readily available in case first emits an element right away.

Type parameters

NameDescription
TFirstThe type of the elements in the first source sequence.
TSecondThe type of the elements in the second source sequence.
TResultThe type of the elements in the result sequence, returned by the selector function.

Parameters

NameTypeDescription
firstIObservableFirst observable source.
secondIObservableSecond observable source.
resultSelectorFuncFunction to invoke for each element from the first source combined with the latest element from the second source, if any.

Returns: IObservable -- An observable sequence containing the result of combining each element of the first source with the latest element from the second source, if any, using the specified result selector function.

Exceptions

TypeCondition
System.ArgumentNullExceptionfirst or second or resultSelector is null.