-
Notifications
You must be signed in to change notification settings - Fork 1
Replace Select and Merge SelectMany
oriches edited this page Mar 24, 2013
·
15 revisions
[Back to Code Analysis & Inspection] (https://github.com/oriches/Resharper.ReactivePlugin/wiki/Code-Analysis-&-Inspection)
Adds a hint highlight to Rx method calls Select & Merge which can be replaced by a single call to SelectMany- it is short hand for calling Select then followed by Merge.
source.Select(selector).Merge();
can be replaced by
source.SelectMany(selector);
So imagine we have to following method with a chain of Rx methods containing a call to Select followed by Merge:
public class ExampleClass
{
public IObservable<int> Method()
{
var n = Observable.Merge(GenerateNumbers(34));
return new List<int> {1, 2, 3}
.ToObservable(Scheduler.Immediate)
.Timeout(TimeSpan.FromSeconds(10), Scheduler.Immediate)
.Select(GenerateNumbers)
.Merge();
}
}