简体   繁体   English

Object.observe撤销和RxJS和Angular 2

[英]Object.observe withdrawal and RxJS and Angular 2

I am a bit confused, because Obejct.observe is said to be withdrawn from the ES2016 . 我有点困惑,因为据说Obejct.observe已退出ES2016

On the other hand there were talks on Angular Connect that mentions they will rely on it. 另一方面, 有关Angular Connect的讨论提到他们会依赖它。

So as far I understand Angular 2 doesn't rely on Object.observe directly but on RxJS which do use the Object.observe 所以到目前为止我理解Angular 2不直接依赖于Object.observe,而是依赖于使用Object.observe的RxJS

Can you please help me understand the impacts of this withdrawal ? 你能帮我理解这次退出的影响吗? I am also confused how this will influence the functional reactive javascript development. 我也很困惑这将如何影响功能性反应性JavaScript开发。

Sorry if it's stupid question, but all these concepts are really new to me. 对不起,如果这是一个愚蠢的问题,但所有这些概念对我来说都是新的。

RxJS doesn't rely on Object.observe (and afaik didn't intend to do so in the future) as RxJS doesn't have a concept of observable objects in itself (you could create objects with observable streams as values though). RxJS不依赖于Object.observe(并且afaik将来不打算这样做)因为RxJS本身没有可观察对象的概念(你可以创建具有可观察流的对象作为值)。

For angular Object.observe would have been relevant, but it didn't rely on it yet I think (or at least not outside chrome). 对于角度Object.observe本来是相关的,但它不依赖它,但我认为(或至少不是外部铬)。

Anyway, if you need observable objects, that is still possible by using the Mobservable library, as explained in this blogpost . 无论如何,如果你需要观察的对象,仍然可以通过使用Mobservable库,在此解释的博文

FYI.... v4.1.0 does have some reliance on Object.observe when using Rx.Observable.ofObjectChanges(obj)... FYI .... v4.1.0在使用Rx.Observable.ofObjectChanges(obj)时确实对Object.observe有所依赖...

Test it yourself in chrome which has now removed support for OO, if you use this method to create an observable you will get an OO error. 在chrome中自己测试,现在已经删除了对OO的支持,如果使用此方法创建一个observable,则会出现OO错误。

So whilst yes, OO has nothing to do with Observables in the context of RxJS, OO is used in 4.1.0 which is current stable and yet to be implemented in 5.XX (which i would guess the delay is due to a switch to Proxy). 因此,虽然是,OO与RxJS上下文中的Observables无关,但是在4.1.0中使用OO是当前稳定的并且尚未在5.XX中实现(我猜这个延迟是由于切换到代理)。

So if you want to use streams and the Rx pattern then no problem, if you want to use RxJS to observe an object, sorry, you will have to polyfill Proxy and use that as ofObjectChanges is broke ATM for chrome stable. 因此,如果你想使用流和Rx模式,那么没问题,如果你想使用RxJS来观察一个对象,抱歉,你将不得不使用polyfill Proxy并使用它,因为ofObjectChanges已经破坏了ATM的chrome stable。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM