Programming Reactive Extensions and Linq

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Pro Reactive Extensions and LINQ is a deep dive into the next important technology for .NET developers: Reactive Extensions. This in-depth tutorial goes beyond what is available anywhere else to teach how to write WPF, Silverlight, and Windows Phone applications using the Reactive Extensions (Rx) to handle events and asynchronous method calls. Reactive programming allows you to turn those aspects of your code that are currently imperative into something much more event-driven and flexible. For this reason, it’s sometimes referred to as LINQ for Events. Reactive programming hinges on the concept of the observable collection, as opposed to the simple enumerable collection with which we’re all familiar. For example, to extract data from a collection and add it to a list box, you would traditionally iterate through the list box, extracting each object in turn. This approach works fine, but it requires significant knowledge about the data you’re working with, which can be limiting. In Rx programming, you're instead informed about each object in turn and then free to react to each notification however you like, which affords much greater flexibility. This book shows you how reactive programming can be applied to a range of situations—from WPF applications to Windows Phone apps—to improve coding efficiency and boost performance. What you’ll learn How to create, debug and manage reactive extensions in many situations The observer pattern and how it can be applied to your projects How to avoid spaghetti code by using Rx to manage your asynchronous methods How to use SelectMany to explore the heart of the Reactive Extensions How to come to grips with the reactive user interface framework for building both small and large applications Who this book is for This book will be most beneficial to existing .NET developers with a grounding in WPF, Silverlight and C#, who want to take their skills further using the powerful reactive programming approach. Table of Contents  Welcome to LINQ and RX Core LINQ Core Rx Practical Rx Inside Rx and LINQ LINQ to SQL Rx and Javascript Reactive UI: Rx and MVVM Testing Rx

Author(s): Jesse Liberty, Paul Betts
Edition: 1
Publisher: Apress
Year: 2011

Language: English
Pages: 182

Cover......Page 169
Contents at a Glance......Page 3
Contents......Page 172
About the Authors......Page 178
About the Technical Reviewer......Page 179
Acknowledgments......Page 180
Foreword......Page 181
Introduction......Page 4
What LINQ Is......Page 5
What Rx Is......Page 6
Distinguishing Rx and LINQ......Page 7
Choosing your IDE......Page 8
Collection Initialization......Page 10
Properties......Page 11
Object Initialization......Page 12
Delegates......Page 13
Lambda Expressions......Page 14
Hello LINQ......Page 16
Collections......Page 17
Observable Collections......Page 18
Example: Working with Enumerable and Observable Collections......Page 19
Summary......Page 22
LINQ Syntax......Page 23
Query Operators......Page 24
Deferred Execution......Page 26
Any......Page 29
Contains......Page 30
Take......Page 31
Zip......Page 32
SelectMany......Page 33
Example: Parsing a Tab Separated File......Page 38
Summary......Page 43
IObservable and IObserver......Page 44
Example: Creating Observables......Page 45
Creating an Observable with Return......Page 46
Creating an Observable from a Range......Page 47
Creating Observables from Events......Page 48
Example: Searching Wikipedia......Page 49
Take......Page 53
Distinct......Page 54
Using......Page 55
Zip......Page 56
Example: Drag and Drop......Page 57
Summary......Page 59
Implementing Asynchronous Calls......Page 60
Using Observable.Return......Page 61
Using FromAsyncPattern......Page 62
Example: Programming Asynchronous Interactions With Rx......Page 64
Add the Bing Service Reference......Page 66
Create the UI......Page 67
Stub the Rx.NET Function Prototypes......Page 69
Implement the Rx.NET Prototypes......Page 70
Implement Rx-based CreateIUmagefromURL......Page 73
Comparing the Traditional Begin/End approach to Rx.Net......Page 77
Summary......Page 79
Window and Buffer......Page 80
Understanding Window: The Core Method......Page 82
Using Join Patterns......Page 84
Using Multicast, Publish and IConnectableObservable......Page 86
Understanding How IObservable Handles OnCompleted and OnError......Page 88
Implementing Your Own Operators......Page 90
Using Schedulers......Page 92
Summary......Page 93
Introducing LINQ to SQL......Page 94
Test LINQ to SQL Queries with LINQPad......Page 95
Writing LINQ to SQL Code with Visual Studio......Page 96
Manipulating Queries with the Take and Skip Operators......Page 99
Sort and Group Results with the orderby and orderby_descending Operators......Page 100
Aggregating and Grouping Results with IEnumerable and Its Extensions......Page 101
Using LINQ to SQL Joins, Cross Joins, and Outer Joins......Page 102
Using LINQ to SQL to Work with Relationships......Page 104
Create the Entity Classes......Page 106
Define the DataContext......Page 108
Write the CreateBooks Event Handler......Page 109
Write the LINQ Queries......Page 111
Summary......Page 112
RxJS Lives in a JavaScript Root Object......Page 113
Using a Browser Console to Explore RxJS......Page 114
Configuring an HTML Page for RxJS......Page 115
Integrating RxJS with jQuery DOM Events......Page 116
Example: Using jQuery DOM Events to Detect a Konami Code......Page 117
Example: Using RxJS with HTML 5 Geolocation and DOM Events......Page 120
Using jQuery AJAX with RxJS......Page 123
Summary......Page 126
The Model-View-ViewModel Pattern......Page 127
Unpacking the ReactiveUI Library......Page 128
Implementing ViewModels with ReactiveObject......Page 129
ReactiveCommand......Page 130
Handling Async Methods via ReactiveAsyncCommand......Page 132
Modeling a Simple Scenario, from Start to Finish......Page 133
Memorizing and Caching in ReactiveUI......Page 135
Using MemorizingMRUCache......Page 136
Calling Web Services in XAML Using ReactiveUI......Page 137
An Important Note on Silverlight......Page 138
Example: Searching Asynchronously for Images with ReactiveUI......Page 139
Design the App for MVVM......Page 140
Pipe IObservable to a Property......Page 141
Summary......Page 145
Mocking Async Methods......Page 146
Simulating the Elapse of Time......Page 147
Using Virtual Schedulers......Page 148
Testing Throttling......Page 149
Testing for a Spinning Spinner......Page 150
Changing Search Terms......Page 151
A......Page 153
C......Page 154
D......Page 155
F......Page 156
I......Page 157
K......Page 158
L......Page 159
M......Page 160
O......Page 161
P......Page 162
R......Page 163
S......Page 165
T......Page 166
W......Page 167
Z......Page 168