O'Reilly logo

Programming Reactive Extensions and LINQ by Paul Betts, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding How IObservable Handles OnCompleted and OnError

Let's examine one critical aspect of the contract offered by IObservable: Once an observable sequence terminates with OnCompleted or OnError, no more items can be produced.

This raises the question: how do you get work done if OnCompleted or OnError interrupt the flow with such finality? This section will examine this dilemma and the solution.

The finality of OnCompleted is illustrated in the following example, which schedules a number of values to be observed, but interrupts with OnCompleted after the second value:

var sched = new TestScheduler(); var input = sched.CreateColdObservable(         sched.OnNextAt(200, 1),         sched.OnNextAt(300, 10),         sched.OnCompletedAt<int>(350.0), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required