Skip to content

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

ReactiveExtensions.FirstMatchFromCandidates(IReadOnlyList, Func>, Func, Func, TResult) method

Defined in

Type: ReactiveExtensions Namespace: ReactiveUI.Extensions Assembly: ReactiveUI.Extensions.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

public static IObservable<TResult> FirstMatchFromCandidates<TKey, TRaw, TResult>(this IReadOnlyList<TKey> candidates, Func<TKey, IObservable<TRaw>> project, Func<TRaw, TResult> transform, Func<TResult, bool> predicate, TResult fallback)

View source

Summary: Walks a list of candidate keys sequentially, projects each into a one-shot observable, transforms the raw value, and emits the first transformed value that satisfies predicate. Errors from individual projections are swallowed (the candidate is skipped). If no candidate matches, emits fallback.

Type parameters

NameDescription
TKeyThe candidate key type.
TRawThe raw element type emitted by the projection.
TResultThe transformed result type.

Parameters

NameTypeDescription
candidatesIReadOnlyListThe ordered list of candidate keys to walk.
projectFunc>Projects a key into a one-shot observable of raw values.
transformFuncTransform applied to each raw value to produce the result.
predicateFuncReturns true for a matching transformed value.
fallbackTResultValue emitted when no candidate matches.

Returns: IObservable -- An observable emitting the first matching transformed value, or fallback.