I'm looking for some way of splitting an observable sequence into separate sequences that I can process independently based on a given predicate. Something like this would be ideal:
var (evens, odds) = observable.Partition(x => x % 2 == 0);
var strings = evens.Select(x => x.ToString());
var floats = odds.Select(x => x / 2.0);
The closest I've been able to come up with is doing two where filters, but that requires evaluating the condition and processing the source sequence twice, which I'm not wild about.
observable = observable.Publish().RefCount();
var strings = observable.Where(x => x % 2 == 0).Select(x => x.ToString());
var floats = observable.Where(x => x % 2 != 0).Select(x => x / 2.0);
F# seems to have good support for this with Observable.partition<'T> and Observable.split<'T,'U1,'U2>, but I've not been able to find anything equivalent for C#.