You can just do this:
IObservable<List<T>> source;
var converted = source.Select(x => x[0]);
Or if you prefer LINQ query comprehension syntax then equivalent is:
var converted = from x in source select x[0];
Question
I'm pretty new to RX and cannot figure this out.
I have an IObservable<List<T>>
where List<T>
is guaranteed to have one element.
How do I convert this to an IObservable<T>
.
I thought it would have something to do with Single
but that is listed as obsolete, and also doesn't return an IObservable<T>
anyway (as pretty sure it would return the Single
List<T>
element.
Is there some SelectMany
magic I can do here?
Solution
You can just do this:
IObservable<List<T>> source;
var converted = source.Select(x => x[0]);
Or if you prefer LINQ query comprehension syntax then equivalent is:
var converted = from x in source select x[0];