Rx.NET in Action
Tamir Dresher
  • MEAP began July 2015
  • Publication in April 2017 (estimated)
  • ISBN 9781617293061
  • 375 pages (estimated)
  • printed in black & white
Rx.NET in Action teaches developers how to build event-driven applications using the Rx library. You'll begin with an overview of the design and architecture of Rx-based reactive applications. Then, this step-by-step guide shows you the rich query capabilities that Rx provides and the Rx concurrency model that allows you to control the asynchronicity of your code and the processing of event handlers. As you move through the book, you'll learn about consuming event streams, using schedulers to manage time, and working with Rx operators to filter, transform, and group events. Readers new to Rx will be able to learn from the ground up. If you're already using Rx, you'll get a deeper look at how to leverage Rx in your existing reactive applications.
Table of Contents detailed table of contents

Part 1: Getting started with Reactive Extensions (Rx)

1. Reactive Programming

1.1. Being Reactive

1.1.1. Reactiveness in your application

1.2. Introducing Reactive Extensions (Rx)

1.2.1. Rx History

1.2.2. Rx on the client and server

1.2.3. Observables

1.2.4. Operators

1.2.5. The composable nature of Rx operators

1.2.6. Marble diagrams

1.2.7. Pull model vs push model

1.3. Reactive systems and the Reactive Manifesto

1.3.1. Responsiveness

1.3.2. Resiliency

1.3.3. Elasticity

1.3.4. Message driven

1.3.5. Where is Rx

1.4. Asynchronicity

1.4.1. It’s all about resource utilization

1.4.2. Asynchronicity and Rx

1.5. Events and streams

1.5.1. Everything is a stream

1.6. Summary

2. Hello Rx

2.1. Working with traditional .NET events

2.1.1. Dealing with concurrency

2.1.2. Retrospective on the solution and looking at the future

2.2. Creating your first Rx application

2.2.1. Rx packages

2.2.2. Installing from NuGet

2.3. Writing the event-processing flow

2.3.1. Subscribing to the event

2.3.2. Grouping stocks by symbol

2.3.3. Finding the difference between ticks

2.3.4. Cleaning resources

2.3.5. Dealing with concurrency

2.3.6. Wrapping up

2.4. Summary

3. Functional thinking in C#

3.1. The advantages of thinking functionally

3.1.1. Declarative programming style

3.1.2. Immutability and side effects

3.1.3. First-class functions

3.1.4. Being concise

3.2. First-class and higher-order functions using delegates and lambdas

3.2.1. Delegates

3.2.2. Anonymous methods

3.2.3. Lambda expressions

3.2.4. Func and Action

3.2.5. Using it all together

3.3. Method chaining with extension methods

3.3.1. Extending type behavior with extension methods

3.3.2. Fluent interfaces and method chaining

3.3.3. Creating a language

3.4. Querying collections with LINQ

3.4.1. What does LINQ look like

3.4.2. Nested queries and joins

3.4.3. Anonymous types

3.4.4. LINQ operators

3.4.5. Efficiency by deferred execution

3.5. Summary

Part 2: Core ideas

4. Creating Observable Sequences

4.1. Creating streams of data and events with observables

4.1.1. Implementing the IObservable<T> interface

4.1.2. The problem with handcrafted observables

4.1.3. The ObservableBase

4.1.4. Creating observables with Observable.Create(…)

4.1.5. Deferring the observable creation

4.2. Creating observables from events

4.2.1. Creating observables that conform to the EventPattern

4.2.2. Events that aren’t following the event pattern

4.2.3. Events with multiple parameters

4.2.4. Dealing with events that has no arguments

4.3. From enumerables to observables and Back

4.3.1. Enumerable to observable

4.3.2. Observable to enumerable

4.4. Using Rx creational operators

4.4.1. Generating an observable loop

4.4.2. Reading a file

4.5. Summary

5. Creating Observables from .NET asynchronous types

5.1. Writing asynchronous code

5.1.1. Asynchronous code in .NET

5.1.2. Task-Based Asynchronous Pattern

5.1.3. Simplifying asynchronous code with async-await

5.1.4. Creating tasks

5.2. Bridging .NET asynchronous types with Rx

5.2.1. Changing the synchronous method to asynchronous

5.2.2. Creating the primes observable

5.2.3. Converting tasks to observables

5.2.4. Running asynchronous code as part of the pipeline

5.2.5. Controlling the results order

5.3. Observables of periodic behavior

5.3.1. Emitting values in time intervals

5.3.2. Creating an observable timer

5.3.3. Scheduling an emission with a timer

5.4. Summary

6. Controlling the Observer-Observable Relationship

6.1. Creating observers

6.1.1. The observable-observer communication

6.1.2. Creating observers without leaving the pipeline

6.1.3. Not passing OnError and asynchronous observables

6.1.4. Replacing the subscription-disposal with cancellation

6.1.5. Creating an observer instance

6.2. Controlling the observable-observer relationship lifetime

6.2.1. Delaying subscription

6.2.2. Stop emitting notifications at a scheduled time

6.2.3. Discarding items when another observable emits

6.2.4. Skipping notifications

6.2.5. Taking or Stopping when a condition is met

6.2.6. Resubscribing

6.2.7. Adding side effects in the observable pipeline

6.3. Putting it all together

6.4. Summary

7. Controlling the Observable Temperature

7.1. Multicasting with Subjects

7.1.1. Simple broadcasting with Subject<T>

7.1.2. Representing asynchronous computation with AsyncSubject

7.1.3. Preserving the latest state with BehaviorSubject

7.1.4. Caching the sequence with ReplaySubject

7.1.5. Hiding your subjects

7.1.6. Subjects best practices and guidelines

7.2. Introducing temperature — Cold and Hot observables

7.2.1. Explaining Cold and Hot observables

7.3. Heating and cooling an observable

7.3.1. Turning cold into hot

7.3.2. ConnectableObservable

7.3.3. Publishing and Multicasting

7.3.4. Multicast

7.3.5. Managing the ConnectableObservable connection

7.3.6. Cooling a hot observable by replaying

7.4. Summary

8. Working with the Basic Query Operators

8.1. Selecting what’s important (mapping)

8.2. Flattening observables

8.2.1. Flattening observables of enumerables

8.2.2. Flattening observables of observables

8.3. Filtering an observable

8.3.1. Filtering with the Where operator

8.3.2. Creating a distinct sequence

8.3.3. Removing duplicate contiguous values

8.4. Aggregating the observable sequence

8.4.1. Basic aggregation operators

8.4.2. Finding the maximum and minimum items by condition

8.4.3. Writing your aggregation logic with Aggregate and Scan

8.5. Summary

9. Partitioning And Combining Observables

9.1. Combining observables

9.1.1. Pairing items from observables (zipping)

9.1.2. Combining the latest emitted values

9.1.3. Concatenating observables

9.1.4. Merging observables

9.1.5. Dynamic concatenating and merging

9.1.6. Switching to the next observable

9.2. Grouping elements from the observable

9.3. Joining observables (coincidence-based combining)

9.3.1. Joining to a flat stream

9.3.2. Joining into groups

9.4. Buffers and sliding windows

9.4.1. Buffering

9.4.2. Windowing the observable sequence

9.5. Summary

10. Working with Rx Concurrency and Synchronization

10.1. Controlling concurrency with schedulers

10.1.1. Defining the scheduler

10.1.2. Parameterizing concurrency

10.1.3. Types of schedulers

10.2. Using time-based operators

10.2.1. Adding a timestamp to a notification

10.2.2. Adding the time interval between notifications

10.2.3. Adding a timeout policy

10.2.4. Delaying the notifications

10.2.5. Throttling the notifications

10.2.6. Sampling the observable in intervals

10.3. Synchronizing the observable emissions

10.3.1. Changing the observations execution context

10.3.2. Changing the subscription/unsubscription execution context

10.3.3. Using SubscribeOn and ObserveOn together

10.3.4. Synchronizing notifications

10.4. Summary

11. Error Handling and Recovering

11.1. Reacting to errors

11.1.1. Errors from the observable side

11.1.2. Catching errors

11.1.3. Retrying to subscribe in case of an error

11.2. Controlling the lifetime of resources

11.2.1. Disposing in a deterministic way

11.2.2. Deterministic finalization

11.2.3. Dangling observers

11.3. Dealing with backpressure

11.3.1. Observables of different rates

11.3.2. Mitigating backpressure

11.4. Summary

Appendixes

Appendix A: Writing Asynchronous Code in .NET

Appendix B: The Rx Disposables Library

Appendix C: Testing Rx Queries and Operators

C.1. Testing Rx code

C.1.1. Writing ReactiveTests with the TestScheduler

C.2. Testing Rx queries

C.2.1. Injecting schedulers

C.2.2. Injecting the TestScheduler

C.3. Summary

About the Technology

In the real world, we're always responding to events and information in our environment. In the same way, modern applications are constantly sending, receiving, and reacting to streams of data including internal messages, user and system events, and sensor input. Reactive Extensions (Rx) is a .NET library that abstracts away the sources of events and provides tools to effectively manage concerns like concurrency, scalability, error handling, and performance. Rx includes more than 600 operators with variants that you can compose together to build reactive client and server-side applications that handle events asynchronously in a way that maximizes responsiveness, resiliency and elasticity.

What's inside

  • Introduction to Rx in C#
  • Creating and consuming streams of data and events
  • Adding your own Rx operators
  • Error handling and testing Rx code

About the reader

Readers should understand OOP concepts and be comfortable coding in C#.

About the author

Tamir Dresher is a senior software architect at CodeValue. A prominent member of Israel's Microsoft programming community, Tamir has trained hundreds of developers to use Reactive Extensions.


Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
Buy
MEAP combo $49.99 pBook + eBook
MEAP eBook $39.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks