I've started to play around with the rx
version of C# recently and am wondering how it's possible to solve the following problem:
I'm using refit to get a list of items from a server via:
[Get("/items")]
IObservable<List<Item>> GetItems();
I would like to process each item afterwards, but I didn't find out how to do that. I know in RxJava there is an operator called flatMapIterable()
which allows me to process each item, but I didn't find something similar for C# .
Thanks
According to the documentation, you need the .SelectMany
.
[Get("/items")]
IObservable<List<Item>> GetItems()
{
observable.SelectMany(t => t);
}
In the Rx.NET repo , you can look at the implementation of the source - if you're interested.
You need SelectMany();
IObservable<List<Item>> observable = new List<List<Item>>().ToObservable();
var flattened = observable.SelectMany(i => i);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.