Skip to content

,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask{System.Boolean}})} ,System.Func{--0,System.Boolean})}

ObservableAsync.Where(IObservableAsync, Func>) method

Defined in

Type: ObservableAsync Namespace: ReactiveUI.Extensions.Async 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

Overloads

  • 1. public static IObservableAsync<T> Where<T>(this IObservableAsync<T> @this, Func<T, CancellationToken, ValueTask<bool>> predicate)
  • 2. public static IObservableAsync<T> Where<T>(this IObservableAsync<T> @this, Func<T, bool> predicate)

1. Overload

public static IObservableAsync<T> Where<T>(this IObservableAsync<T> @this, Func<T, CancellationToken, ValueTask<bool>> predicate)

View source

Summary: Creates a new observable sequence that contains only the elements from the source sequence that satisfy the specified asynchronous predicate.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
predicateFunc>A function that evaluates each element and its associated cancellation token, returning a ValueTask that resolves to true to include the element in the resulting sequence; otherwise, false.

Returns: IObservableAsync -- An observable sequence that emits only those elements for which the predicate returns true.

Remarks

The predicate is invoked asynchronously for each element as it is observed. If the predicate throws an exception or the ValueTask is faulted, the resulting sequence will propagate the error to its observers. The cancellation token provided to the predicate can be used to observe cancellation requests during predicate evaluation.

2. Overload

public static IObservableAsync<T> Where<T>(this IObservableAsync<T> @this, Func<T, bool> predicate)

View source

Summary: Creates a new observable sequence that contains only the elements from the current sequence that satisfy the specified predicate.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
predicateFuncA function to test each element for a condition. The element is included in the resulting sequence if the function returns true.

Returns: IObservableAsync -- An observable sequence that contains elements from the current sequence that satisfy the specified predicate.

Remarks

The resulting observable emits only those elements for which the predicate returns true. The order and timing of element emission are preserved from the original sequence.