,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)
Summary: Creates a new observable sequence that contains only the elements from the source sequence that satisfy the specified asynchronous predicate.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
predicate | Func | 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: IObservableAsynctrue.
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)
Summary: Creates a new observable sequence that contains only the elements from the current sequence that satisfy the specified predicate.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
predicate | Func | A function to test each element for a condition. The element is included in the resulting sequence if the function returns true. |
Returns: IObservableAsync
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.