Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Foreword

Preface

Acknowledgments

About this Book

About the Author

About the Cover Illustration

1. Getting started with Reactive Extensions

Chapter 1. Reactive programming

1.1. Being reactive

1.1.1. Reactiveness in your application

1.2. Introducing Reactive Extensions

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. Working with 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. Understanding asynchronicity

1.4.1. It’s all about resource use

1.4.2. Asynchronicity and Rx

1.5. Understanding events and streams

1.5.1. Everything is a stream

1.6. Summary

Chapter 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. Selecting 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

Chapter 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

2. Core ideas

Chapter 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 have 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.4.3. The primitive observables

4.5. Summary

Chapter 5. Creating observables from .NET asynchronous types

5.1. Bridging .NET asynchronous types with Rx

5.1.1. Changing the synchronous method to asynchronous

5.1.2. Creating the primes observable

5.1.3. Using async-await in observable creation

5.1.4. Converting tasks to observables

5.1.5. Running asynchronous code as part of the pipeline

5.1.6. Controlling the results order

5.2. Creating observables of periodic behavior

5.2.1. Emitting values in time intervals

5.2.2. Creating an observable timer

5.2.3. Scheduling an emission with a timer

5.3. Summary

Chapter 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

Chapter 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. Following best practices and guidelines

7.2. Introducing temperature: cold and hot observables

7.2.1. Explaining cold and hot observables

7.2.2. Cold observable

7.2.3. Hot observables

7.3. Heating and cooling an observable

7.3.1. Turning cold into hot

7.3.2. Using ConnectableObservable

7.3.3. Publishing and multicasting

7.3.4. Using Multicast

7.3.5. Managing the ConnectableObservable connection

7.3.6. Cooling a hot observable to allow replaying

7.4. Summary

Chapter 8. Working with 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. Using 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

Chapter 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

Chapter 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 time-out 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 observation’s 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

Chapter 11. Error handling and recovery

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

Appendix A. Writing asynchronous code in .NET

A.1. Writing asynchronous code

A.2. Asynchronous code in .NET

A.3. Task-Based Asynchronous Pattern

A.4. Simplifying asynchronous code with async-await

A.5. Creating tasks

A.6. Summary

Appendix B. The Rx Disposables library

B.1. Disposable.Create

B.2. Disposable.Empty

B.3. ContextDisposable

B.4. ScheduledDisposable

B.5. SerialDisposable

B.6. RefCountDisposable

B.7. MultipleAssignmentDisposable

B.8. CompositeDisposable

B.9. SingleAssignmentDisposable

B.10. CancellationDisposable

B.11. BooleanDisposable

B.12. Summary

Appendix C. Testing Rx queries and operators

C.1. Testing Rx code

C.1.1. Writing reactive tests with the TestScheduler

C.1.2. Observing the TestableObservable

C.1.3. Testing concurrent Rx code

C.1.4. Finer control on the TestScheduler

C.2. Testing Rx queries

C.2.1. Injecting schedulers

C.2.2. Injecting the TestScheduler

C.3. Summary

 Catalog of Rx operators

Index

List of Figures

List of Tables

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.37.154