Book Image

Reactive Programming for .NET Developers

Book Image

Reactive Programming for .NET Developers

Overview of this book

Reactive programming is an innovative programming paradigm focused on time-based problem solving. It makes your programs better-performing, easier to scale, and more reliable. Want to create fast-running applications to handle complex logics and huge datasets for financial and big-data challenges? Then you have picked up the right book! Starting with the principles of reactive programming and unveiling the power of the pull-programming world, this book is your one-stop solution to get a deep practical understanding of reactive programming techniques. You will gradually learn all about reactive extensions, programming, testing, and debugging observable sequence, and integrating events from CLR data-at-rest or events. Finally, you will dive into advanced techniques such as manipulating time in data-flow, customizing operators and providers, and exploring functional reactive programming. By the end of the book, you'll know how to apply reactive programming to solve complex problems and build efficient programs with reactive user interfaces.
Table of Contents (15 chapters)
Reactive Programming for .NET Developers
About the Authors
About the Reviewer


Reactive programming is the programming paradigm for handling continuous changing messages and their notifications. Instead of developing static value changes, we develop data changes. This slight difference leaves the developer facing issues regarding high speed messaging systems that handle such messages in a completely new way. Reactive programming means writing functions that transform messages. This means that something, such as an exception within the reactive world became a message. This book will cover Reactive programming with Reactive extensions for .NET in an increasing complex approach. In the final chapters, the reader will find real-world solutions and learn about F# functional reactive programming.

What this book covers

Chapter 1 , First Steps in Reactive Programming, covers what Reactive programming is: the idea, the overall design, the available frameworks, and the languages supporting this incredible programming paradigm.

Chapter 2 , Reactive Programming with C#, will show Reactive programming in action in plain C# coding without the need for any external reference. In this way, any developer may bring reactive programming knowledge to any existing application.

Chapter 3 , Reactive Extension Programming, explains RX basics, such as the Observable sequence, message consumers (Observer), and the most widely used reactive operators, such as message transforming and message grouping functions.

Chapter 4 , Observable Sequence Programming, will teach you how to produce, consume, and route messages with subjects and learn the Rx operator catalog. You will also see operators that apply message filtering, aggregation, transformation, generation, and time-based operations.

Chapter 5 , Debugging Reactive Extensions, will deal with debugging and tracing observable sequences. It focuses on handling exceptions, routing errors, and notifying users about application issues in order to improve application reliability and maintainability.

Chapter 6 , CLR Integration and Scheduling, covers how to source or send messages with plain CLR objects and how to achieve time scheduling and multithreading easily with Rx programming.

Chapter 7, Advanced Techniques , will show Rx in action with real-world solutions and explain how to create new operators or how to use the Rx features in classic .NET development.

Chapter 8 , F# and Functional Reactive Programming, presents the F# language and key points of functional programming. It describes Functional Reactive Programming (FRP) with a few examples of push-based and pull-based scenarios, the event data flow, and type events in F#.

Chapter 9, Advanced FRP and Best Practices , delves deep into advanced FRP concepts through the study of discrete and continuous components and the concepts of time flow and dynamic change. It also discusses Railway-oriented programming and F# observable.

What you need for this book

For this book, you will require an updated version Visual Studio 2013 or 2015.The Reactive Extensions library pack is available from the NuGet package explorer by searching "Rx-main". Examples from the book require other packages as well; in these cases, a reference within the chapter itself will specify the required package's name.

Who this book is for

If you are an experienced C# developer with no pre-existing knowledge of Rx development, this book is for you. The book is useful as a Rx reference manual.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Later, a counter variable will make the most of the work to find the distance between the two numbers."

A block of code is set as follows:

//procedural style
var sourceData = new { TotalAmount = 12345.67, PaidAmount = 12345.67 };
if (sourceData.PaidAmount == sourceData.TotalAmount)
    //do something


The NuGet package names have been changed. The Rx-* and Ix-* packages have been renamed to match their library names, keeping inline with the rest of .NET Core.

  • Use System.Reactive instead of Rx-Main

  • Use System.Interactive instead of Ix-Main

  • Use System.Interactive.Async instead of Ix-Async

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "As you can see, the diagram depicts three functions held in the Computation Expression that return Success or Failure."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at We also have other code bundles from our rich catalog of books and videos available at Check them out!


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.