dotnet / reactive

The Reactive Extensions for .NET
http://reactivex.io
MIT License
6.73k stars 751 forks source link

[Feature] DistinctBy for IAsyncEnumerable #1986

Open WhatzGames opened 1 year ago

WhatzGames commented 1 year ago

For the IEnumerable DistinctBy was already added in .Net 6.

This feature is currently missing for the IAsynEnumerable.

I therefore propose to add the following API:

public static IAsyncEnumerable<TSource> DistinctBy<TSource, TKey>(this IAsyncEnumerable<T> source,  Func<TSource, TKey> keySelector);
public static IAsyncEnumerable<TSource> DistinctBy<TSource, TKey>(this IAsyncEnumerable<T> source,  Func<TSource, TKey> keySelector, IEqualityComparer<TKey>);
public static IAsyncEnumerable<TSource> DistinctBy<TSource, TKey>(this IAsyncEnumerable<T> source,  Func<TSource, ValueTask<TKey>> keySelector);
public static IAsyncEnumerable<TSource> DistinctBy<TSource, TKey>(this IAsyncEnumerable<T> source,  Func<TSource, valueTask<TKey>> keySelector, IEqualityComparer<TKey>);

If approved, I would like to give it a try myself.

MatthewSteeples commented 3 months ago

Related to #2048

TonyValenti commented 3 months ago

I wanted to post here that we could really use DistinctBy for IAsyncEnumerable.