I'm new to Rx and I'm thinking what happens when IObservable is producing lot of events very quickly and OnNext take very long time. I guess that new events are queued somehow internally so I can possible run our memory. Am I right? Consider following small example:
Subject<int> subject = new Subject<int>();
subject.ObserveOn(Scheduler.ThreadPool).Subscribe(x => { Console.WriteLine("Value published: {0}", x); Thread.Sleep(100); },
() => Console.WriteLine("Sequence Completed."));
for (int i = 0; i < 10; i++)
{
subject.OnNext(i);
}
I publish 10 events and consumer method is very slow. All events are processed so it must be cached in memory. In case that I publish lot of events I will run out of memory, correct? Or do I miss something?
Is there a way how to limit count of pending events in reactive extensions? For example where there is more than 5 pending events I want to omit new ones.