,System.Func{--0,--1})} ,System.Func{--0,--1},System.Collections.Generic.IEqualityComparer{--1})}
ObservableAsync.DistinctBy(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> DistinctBy<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector) - 2.
public static IObservableAsync<T> DistinctBy<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, IEqualityComparer<TKey> equalityComparer)
1. Overload¶
public static IObservableAsync<T> DistinctBy<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector)
Summary: Returns a sequence that contains distinct elements from the source sequence according to a specified key selector function.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
TKey | The type of the key returned by the key selector function. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
keySelector | Func | A function to extract the key for each element. Cannot be null. |
Returns: IObservableAsync
Remarks
Elements are considered distinct based on the value returned by the key selector and the default equality comparer for the key type.
2. Overload¶
public static IObservableAsync<T> DistinctBy<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, IEqualityComparer<TKey> equalityComparer)
Summary: Returns an observable sequence that contains only distinct elements from the source sequence, comparing values based on a specified key and equality comparer.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
TKey | The type of the key used to determine the distinctness of elements. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
keySelector | Func | A function to extract the key for each element. Cannot be null. |
equalityComparer | IEqualityComparer | An equality comparer to compare keys for equality. Cannot be null. |
Returns: IObservableAsync
Remarks
Elements are considered distinct based on the value returned by the keySelector function and compared using the provided equalityComparer. Only the
first occurrence of each key is included in the resulting sequence.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if keySelector or equalityComparer is null. |