dotnet / reactive

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

Consider adding higher-order overload for Amb #2165

Open glopesdev opened 2 months ago

glopesdev commented 2 months ago

Feature request

Which next library version (i.e., patch, minor or major)?

minor

What are the platform(s), environment(s) and related component version(s)?

all platforms

Please describe the feature.

Add a higher-order overload to Amb with the following signature:

public static IObservable<TSource> Amb<TSource>(IObservable<IObservable<TSource>> sources)

Amb currently exposes an overload with IEnumerable<IObservable<TSource>> allowing for dynamically evaluated sequences of observables competing to react first, but strangely it does not provide the fully reactive counterpart with IObservable<IObservable<TSource>>.

This would allow for candidate sequences to be computed reactively. The main difference would be not waiting for all sequences to be available before subscribing to candidates. The first sequence to emit a notification would surface all its notifications. All subscriptions to other sequences, including the higher-order sequence, would be cancelled.