Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Is there an example of Ix.NET (System.Interactive) somwehere?

nawfal:

I have an Async method, say:


public async Task GetAsync()
{

}

and would be called from:


public async Task> GetAllAsync()
{
foreach (var item in something)
{
var result = await GetAsync();
yield return result;
}
}

The above syntax is not valid but basically I am after asynchronous generators. I know it can be handled via Observables. I did experiment with Rx.NET and it worked to some extent. But I am trying to avoid the complexity it brings to codebase, and more importantly the above requirement is still essentially not a reactive system (ours is still pull based). For e.g. I would only listen to the incoming async streams for a certain time and I have to stop the producer (not just unsubscribe the consumer) from the consumer side.

I can invert the method signature like this:


public IEnumerable> GetAllAsync()

But this makes doing LINQ operations bit tricky without blocking. I want it to be non-blocking as well as without loading the entire thing into memory. This library: https://github.com/tyrotoxin/AsyncEnumerable does exactly what I am looking for but how can the same be done with Ix.NET? They are meant for the same thing I believe.

In other words, how can I make use of Ix.NET to generate an IAsyncEnumerable when dealing with await? Like,


public async IAsyncEnumerable GetAllAsync()
{
foreach (var item in something)
{
var result = await GetAsync();
return // what?
}
}



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Is there an example of Ix.NET (System.Interactive) somwehere?

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×