开发者

Killer benefit of Reactive Extensions?

开发者 https://www.devze.com 2023-01-04 15:11 出处:网络
What is the killer benefit of Reactive Extensions (for either .NET or JavaScript)? Why should a developer learn and use th开发者_如何转开发em?Reactive Extensions gives developers a way to compose comp

What is the killer benefit of Reactive Extensions (for either .NET or JavaScript)? Why should a developer learn and use th开发者_如何转开发em?


Reactive Extensions gives developers a way to compose complex event processing and asynchronous computation across Observable collections using a much more functional and declarative syntax.

A fairly simple example can be found at:

Mike Chaliy: Reactive Extensions AI: Domain Events Example

The clincher for me, even on a simple example, is this:

...notify manager about all noticeable transfers.

Account.TransferMoney
       .Where(_ => _.Amount > 100.0m)
       .Subscribe(_ => SendMessageToManager());

As you can see, subscribing using Rx clearly defines our intent in a clear and concise manor. You can imagine chaining together complex logic (much like a complex LINQ query) to make some very interesting functionality.

You might also want to take a look at:

Reactive Framework (Rx) Wiki: (not yet) 101 Rx Samples

0

精彩评论

暂无评论...
验证码 换一张
取 消