Object.observe withdrawal and RxJS and Angular 2

1.2k Views Asked by At

I am a bit confused, because Obejct.observe is said to be withdrawn from the ES2016.

On the other hand there were talks on Angular Connect that mentions they will rely on it.

So as far I understand Angular 2 doesn't rely on Object.observe directly but on RxJS which do use the Object.observe

Can you please help me understand the impacts of this withdrawal ? I am also confused how this will influence the functional reactive javascript development.

Sorry if it's stupid question, but all these concepts are really new to me.

2

There are 2 best solutions below

0
mweststrate On BEST ANSWER

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).

For angular Object.observe would have been relevant, but it didn't rely on it yet I think (or at least not outside chrome).

Anyway, if you need observable objects, that is still possible by using the Mobservable library, as explained in this blogpost.

0
Paul On

FYI.... v4.1.0 does have some reliance on Object.observe when using Rx.Observable.ofObjectChanges(obj)...

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.

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.X.X (which i would guess the delay is due to a switch to Proxy).

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.