6 Real-time event streams: functional reactive programming

 

This chapter covers

  • Understanding queryable event streams
  • Working with Reactive Extensions (Rx)
  • Combining F# and C# to make events first-class values
  • Processing high-rate data streams
  • Implementing a Publisher-Subscriber pattern

We’re used to responding to events in our lives daily. If it starts to rain, we get an umbrella. If the daylight in a room begins to dim, we flip the switch to turn on the electric light. The same is true in our applications, where a program must react to (or handle) events caused by something else happening in the application or a user interacting with it. Almost every program must handle events, whether they’re the receipt of an HTTP request for a web page on a server, a notification from your favorite social media platform, a change in your filesystem, or a simple click of a button.

6.1 Reactive programming: big event processing

6.2 .NET tools for reactive programming

6.2.1 Event combinators—a better solution

6.2.2 .NET interoperability with F# combinators

6.3 Reactive programming in .NET: Reactive Extensions (Rx)

6.3.1 From LINQ/PLINQ to Rx

6.3.2 IObservable: the dual IEnumerable

6.3.3 Reactive Extensions in action

6.3.4 Real-time streaming with RX

6.3.5 From events to F# observables

6.4 Taming the event stream: Twitter emotion analysis using Rx programming

6.4.1 SelectMany: the monadic bind operator

6.5 An Rx publisher-subscriber

6.5.1 Using the Subject type for a powerful publisher-subscriber hub

6.5.2 Rx in relation to concurrency

6.5.3 Implementing a reusable Rx publisher-subscriber

6.5.4 Analyzing tweet emotions using an Rx Pub-Sub class

6.5.5 Observers in action

6.5.6 The convenient F# object expression

Summary