Skip to content

,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)

View source

Summary: Returns a sequence that contains distinct elements from the source sequence according to a specified key selector function.

Type parameters

NameDescription
TThe type of the elements in the source sequence.
TKeyThe type of the key returned by the key selector function.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
keySelectorFuncA function to extract the key for each element. Cannot be null.

Returns: IObservableAsync -- An observable sequence that contains only the first occurrence of each distinct key as determined by the key selector.

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)

View source

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

NameDescription
TThe type of the elements in the source sequence.
TKeyThe type of the key used to determine the distinctness of elements.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
keySelectorFuncA function to extract the key for each element. Cannot be null.
equalityComparerIEqualityComparerAn equality comparer to compare keys for equality. Cannot be null.

Returns: IObservableAsync -- An observable sequence that contains only the first occurrence of each distinct key as determined by the specified key selector and equality comparer.

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

TypeCondition
System.ArgumentNullExceptionThrown if keySelector or equalityComparer is null.