using System.Collections.Generic;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
public static async Task Main()
var obs = await FibonacciAsync(4).Take(10).ToObservable().LastAsync();
private static IAsyncEnumerable<int> FibonacciAsync(int batchSize = 100)
return FibonacciAsyncBatches(batchSize).SelectMany(batch => batch.ToAsyncEnumerable());
private static async IAsyncEnumerable<IEnumerable<int>> FibonacciAsyncBatches(int batchSize = 100)
Console.Out.WriteLine("Fetching batch {0} to {1}", skip, skip + batchSize);
yield return fib.Skip(skip).Take(batchSize);
skip = (skip + batchSize);
private static IEnumerable<int> Fibonacci()
int current = 1, next = 1;
next = current + (current = next);