react开源_React性扩展(Rx)现在是开源的

微软开放技术宣布React的Reactive Extensions(Rx)现在开源,包括Rx.NET、RxJS和Rx++等库,允许开发者使用可观察序列和LINQ风格的查询运算符来处理异步和事件驱动的程序。Rx有助于简化事件管理和异步操作,改善测试,并已在GitHub的Windows和Mac产品中得到广泛应用。
摘要由CSDN通过智能技术生成
react开源

react开源

A few years back I did a podcast with Erik Meijer about Reactive Extensions for .NET (Rx). Since then thousands of people have enjoyed using Rx in the projects and a number of open source projects like ReactiveUI (also on the podcast) have popped up around it. Even GitHub for Windows uses Reactive Extensions. In fact, GitHub uses Rx a LOT in their Windows product. My friend Paul at GitHub says they liked the model so much they made a Mac version!

几年前,我与Erik Meijer进行了有关.NET(Rx)的Reactive Extensions的播客。 从那时起,成千上万的人在项目中使用Rx,并在它周围弹出了许多开源项目,例如ReactiveUI (也在podcast上)。 甚至Windows的GitHub都使用Reactive Extensions 。 实际上,GitHub在Windows产品中使用Rx LOT。 我在GitHub上的朋友Paul说他们非常喜欢该模型,因此制作了Mac版本!

“GitHub for Windows uses the Reactive Extensions for almost everything it does, including network requests, UI events, managing child processes (git.exe). Using Rx and ReactiveUI, we've written a fast, nearly 100% asynchronous, responsive application, while still having 100% deterministic, reliable unit tests. The desktop developers at GitHub loved Rx so much, that the Mac team created their own version of Rx and ReactiveUI, called ReactiveCocoa, and are now using it on the Mac to obtain similar benefits.” – Paul Betts, GitHub

“适用于Windows的GitHub在几乎所有功能上都使用了Reactive Extensions,包括网络请求,UI事件,管理子进程(git.exe)。 使用Rx和ReactiveUI,我们编写了一个快速的,接近100%的异步,响应式应用程序,同时仍具有100%的确定性,可靠的单元测试。 GitHub的桌面开发人员非常喜欢Rx,Mac团队创建了他们自己的Rx和ReactiveUI版本,称为ReactiveCocoa,现在正在Mac上使用它来获得类似的收益。” – Paul Betts,GitHub

Today, Microsoft Open Technologies announced the open sourcing of Reactive Extensions! You can get the code with git up on Codeplex at https://rx.codeplex.com. You can’t stop the open source train! Congrats to the team!

今天,微软开放技术宣布了开源React扩展! 您可以在https://rx.codeplex.com上的Codeplex上使用git来获取代码。 您不能停止开源火车! 恭喜团队!

There’s a LOT included, so be stoked. It’s not just Rx.NET, but also the C++ library as well as RxJS for JavaScript! Now everyone gets to play with IObservable<T> and IObserver<T>.

其中包括很多,所以很激动。 它不仅是Rx.NET,还包括C ++库以及JavaScript的RxJS! 现在,每个人都可以使用IObservable <T>和IObserver <T>。

  • Reactive Extensions:

    React性扩展:

    • Rx.NET: The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators.

      Rx.NET:Reactive Extensions(Rx)是一个库,用于使用可观察的序列和LINQ样式的查询运算符来组成异步和基于事件的程序。
    • RxJS: The Reactive Extensions for JavaScript (RxJS) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in JavaScript which can target both the browser and Node.js.

      RxJS:JavaScript的Reactive Extensions(RxJS)是一个库,用于使用JavaScript中的可观察序列和LINQ样式查询运算符来组合异步和基于事件的程序,这些操作符可以同时针对浏览器和Node.js。
    • Rx++: The Reactive Extensions for Native (RxC) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.

      Rx ++:本机响应式扩展(RxC)是一个库,用于在C和C ++中使用可观察的序列和LINQ样式的查询运算符来组成异步和基于事件的程序。
  • Interactive Extensions

    互动扩展

    • Ix: The Interactive Extensions (Ix) is a .NET library which extends LINQ to Objects to provide many of the operators available in Rx but targeted for IEnumerable<T>.

      Ix:交互式扩展(Ix)是一个.NET库,它将LINQ扩展到对象,以提供Rx中可用但针对IEnumerable <T>的许多运算符。
    • IxJS: An implementation of LINQ to Objects and the Interactive Extensions (Ix) in JavaScript.

      IxJS:LINQ to Objects和JavaScript中的交互式扩展(Ix)的实现。
    • Ix++: An implantation of LINQ for Native Developers in C++

      IX ++:LINQ为C ++的本机开发人员的植入

A great way to learn about why Rx is useful is to check out the Rx Koan’s project or to read the IntroToRx online e-book.

了解Rx为何有用的一种好方法是查看Rx Koan的项目或阅读IntroToRx在线电子书

Why do I think Rx matters? It’s a way to do asynchronous operations on event streams. Rather than hooking up click events and managing state with event handlers all over, you effectively “query” an infinite stream of events with LINQ. You can declaratively sequence events…no flags, no state machine.

为什么我认为Rx很重要? 这是对事件流执行异步操作的一种方式。 您无需挂接单击事件并使用事件处理程序管理状态,而是可以使用LINQ有效地“查询”无限事件流。 您可以声明性地对事件进行排序……没有标志,没有状态机。

For example, here’s a dragging event created (composed) via Mouse button and Mouse move events:

例如,以下是通过鼠标按钮和鼠标移动事件创建(组成)的拖动事件:

IObservable<Event<MouseEventArgs>> draggingEvent =
from mouseLeftDownEvent in control.GetMouseLeftDown()
from mouseMoveEvent in control.GetMouseMove().Until(control.GetMouseLeftUp())
select mouseMoveEvent;

Even better, Rx makes it easier (or possible!) to create event-based tests that are asynchronous, like this example from Jafar Husain:

更好的是,Rx使创建异步事件基于测试的测试变得更加容易(或可能!),例如Jafar Husain的示例

Rating rating = new Rating();
IObservable<Unit> test = // Unit is an object that represents null.
ObservableExtensions
.DoAsync(() => TestPanel.Children.Add(rating))
.WaitFor(TestPanel.GetLayoutUpdated()) // Extension method GetLayoutUpdated converts the event to observable
.DoAsync(() => rating.Value = 1.0) // Calls the Ignite EnqueueCallback method
.WaitFor( // waits for an observable to raise before going on
// listen to all the actual value change events and filters them until ActualValue reaches Value
rating
.GetActualValueChanged() // extension method that converts ActualValueChanged event to IObservable
.SkipWhile(actualValueChangedEvent => actualValueChangedEvent.EventArgs.NewValue != rating.Value))
// check to make sure the actual value of the rating item is set appropriately now that the animation has completed
.Assert(() => rating.GetRatingItems().Last().ActualValue == 1.0) // crawls the expression tree and makes a call to the appropriate Assert method

Test.Subscribe(() => TestPanel.Children.Remove(rating)); //run the test and clean up at the end.

There’s amazing Time-related operators that let you simulate events over time. Note the Buffer and Subscribe calls.

与时间相关的惊人运算符可让您随时间推移模拟事件。 请注意缓冲区和订阅调用。

var myInbox = EndlessBarrageOfEmail().ToObservable();

// Instead of making you wait 5 minutes, we will just check every three seconds instead. :)
var getMailEveryThreeSeconds = myInbox.Buffer(TimeSpan.FromSeconds(3)); // Was .BufferWithTime(...

getMailEveryThreeSeconds.Subscribe(emails =>
{
Console.WriteLine("You've got {0} new messages! Here they are!", emails.Count());
foreach (var email in emails)
{
Console.WriteLine("> {0}", email);
}
Console.WriteLine();
});

You can use await and async, like in this example returning the number 42 after 5 seconds:

您可以使用await和async,例如在本示例中,在5秒后返回数字42:

static async void button_Click()
{
int x = await Observable.Return(42).Delay(TimeSpan.FromSeconds(5));
// x with value 42 is returned after 5 seconds
label.Text = x.ToString();
}
I’m just showing you the parts that tickle me, but one could easily teach a 10 week university course on Rx, and I’m still a beginner myself!

Here’s some more resources to check out about Rx. Congrats to the team for their contribution to Open Source!

这里是更多有关Rx的资源。 祝贺团队为开源做出的贡献!

翻译自: https://www.hanselman.com/blog/reactive-extensions-rx-is-now-open-source

react开源

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值