Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Chrome 50 breaks this lib #130

Open
Bretto opened this issue Apr 20, 2016 · 11 comments
Open

Chrome 50 breaks this lib #130

Bretto opened this issue Apr 20, 2016 · 11 comments

Comments

@Bretto
Copy link

Bretto commented Apr 20, 2016

After updating to Chrome 50 we are not notified of object changes anymore

@addyosmani
Copy link
Contributor

Could you provide a minimal test case that breaks so we can confirm if this is the case? Are there any exceptions in particular being thrown when using it?

@Bretto
Copy link
Author

Bretto commented Apr 20, 2016

var obj = { foo: 1 };
var observer = new PathObserver(obj, 'foo');
observer.open(function(newValue, oldValue) {
  console.log(newValue, oldValue);
});

var obj = { foo: 2 };

The console.log is not called on change, and no there was to errors

@Bretto
Copy link
Author

Bretto commented Apr 20, 2016

I tested that a work on a Window and Linux, haven't tried on a mac

@RadikFakhriev
Copy link

RadikFakhriev commented Apr 20, 2016

I confirm this. ArrayObserver is not working too. In Chrome 50 and FF 44/45 on Windows.
Code for testing:

var errorFields = [],
observerErrorFields = new ArrayObserver(errorFields);

observerErrorFields.open(function (splices) {
    alert("it's work!");
});

errorFields.push("item");

alert is not called on change, and no there was to errors

@RadikFakhriev
Copy link

I think this problem is caused by problem described in #127 issue
Current situation on MDN: Object.observe() is obsolete

@mezaof
Copy link

mezaof commented Apr 21, 2016

So what's our alternative ? Is there a any other trick for observing objects ?

@addyosmani
Copy link
Contributor

@Bretto @fakrex thanks for confirming.

I personally recommend using https://github.com/MaxArt2501/object-observe (for the time being) until it's more clear what the support strategy around the observe-js shim is moving forward. I'm happy to review PRs that attempt to address breakage in Chrome 50 if there are folks actively relying on this for production apps.

@mathiasmoeller
Copy link

+1

@gaurav21r
Copy link

@addyosmani Thanks for your comment. If we look at both libraries there are some discussions back and forth comparing the Object.observe polyfill and observe-js.

As I can gather (correct me if I am wrong), this library was / is used by Polymer (at least during the 0.5 era) to implement Data Binding. From your comment, can it be inferred as though this not currently used by the Polymer team? If not, how is Polymer (1.0) now checking for property changes?

We have built a library around observe-js and that powers multiple apps / sites in production. A rough indication on the road ahead for this library would be super! 👍

@mbana
Copy link

mbana commented Aug 19, 2016

See: #131.
I had to do the notify manually.

Can a check not be included at the time of library inclusion to display a warning that a manual call is needed?

@YingshanDeng
Copy link

Hello, from the source code and the Polymer framework source code, I found the reason. The object-observe is based on dirty check, so we should setup up the loop for object observation and change notification. For example, in Polymer framework, at the end of the file observe-js-behavior.html, I found that:

// Poll observe-js all the time
setInterval(Platform.performMicrotaskCheckpoint, 125);

So, when we use this polyfill for our project, we need manually call for the dirty check.Such as setInterval or requestAnimationFrame. And what do you think? 👊 @Bretto @addyosmani Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants