Reactive Extensions

0
119

data, such as the Accelerometer or the Location Service, you must often manage multiple concurrent streams of information. Other
scenarios in which the same requirements occur are when composing information returned from multiple concurrent requests to remote services, or when you need to handle inputs such as recording sound. In addition, if you are building and testing applications using an emulator instead of a physical device, some of the device capabilities (such as the Accelerometer) are not available. In these situations, you may find the Reactive Extensions (Rx) for .NET feature useful.

The reactive extensions also allow you to write compact, declarative code to manage complex, asynchronous operations.

Reactive extensions allow you to do the following:

  • Represent data streams, asynchronous requests, and events as observable sequences to which applications and components can subscribe.
  • Compose multiple streams into a single stream.
  • Define queries that filter streams to select only specific data items.
  • Apply transformations to data streams.
  • Emulate data streams that are not available in the current environment (such as a device emulator).
  • Read and write the streams to storage on the device, and play them back when required.

The majority of operations you perform with reactive extensions are implemented by the Observable class, which exposes a large number
of methods for creating, merging, manipulating, and querying streams. For a full list of these methods, see “Observable Members” on MSDN (http://msdn.microsoft.com/en-us/library/microsoft.phone.reactive.observable_members(VS.92).aspx).

For more information about reactive streams, see “Reactive Extensions for .NET Overview for Windows Phone” (http://msdn.microsoft.
com/en-us/library/ff431792(VS.92).aspx) and “How to: Use Reactive Extensions to Emulate and Filter Location Data for Windows Phone” (http://msdn.microsoft.com/en-us/library/ff637517(VS.92).aspx) on MSDN. You can also download a code sample that demonstrates
using the reactive extensions from “Code Samples for Windows Phone” on MSDN (http://msdn.microsoft.com/en-us/library/ff431744(VS.92).aspx).

The URL to the bibliography can be found in the preface, in the final section, entitled, “Where to Go for More Information.”