Rx框架简介,及在观察者模式中的应用

时间:2021-07-26 09:12:38

RX框架是Reactive Framework (Rx) ,它是一个异步通知的框架,有点类似观察者模式,只不过它是异步的,不会因为监听请求而阻塞通道

Why use Rx?

One of the advantages of using Rx with the observer pattern is that publishers in Rx run asynchronously, so that program execution does not get blocked while the publisher is busy retrieving data. Instead, callbacks are used to notify subscribers when data is available. Callbacks are also used to inform subscribers if there is an error and when the sequence has ended. This avoids the situation where subscribers are continuing to observe events that have either finished or faulted. Rx also facilitates the use of Linq for filtering, grouping and composing data and there are methods available for testing as well as carrying out time-related processing such as buffering and throttling.


说明文档: http://msdn.microsoft.com/en-us/library/hh242981(v=vs.103).aspx

Wiki地址:http://rxwiki.wikidot.com/start

Using Rx

2 out of 3 rated this helpful Rate this topic

This section includes topics that explain how you use Rx to create and subscribe to sequences, bridge existing .NET events and existing asynchronous patterns, as well as using schedulers. It also describes more advanced tasks such as testing and debugging an observable sequence, as well as implementing your own operators.

In This Section

  1. Exploring The Major Interfaces in Rx 

  2. Creating and Querying Observable Sequences 

  3. Subjects 

  4. Scheduling and Concurrency 

  5. Testing and Debugging Observable Sequences 

  6. Implementing Your Own Operators for IObservable 

  7. Using Observable Providers 

Reference

System.Reactive System.Reactive.Linq System.Reactive.Concurrency System.Reactive.Subjects

RX在观察者模式中的应用: http://www.codeproject.com/Articles/773886/Implementing-the-Observer-Pattern-using-Rx