2 comments

[ 4.9 ms ] story [ 25.0 ms ] thread
This looks really interesting but there are a few caveats wrt Arrays:[1]

"Due to limitations of native arrays in ES5 (array.observe is only available in ES7, and arrays cannot be extend),..."

"Bear in mind that Array.isArray(observable([])) will yield false, so whenever you need to pass an observable array to an external library, it is a good idea to create a shallow copy before passing it... "

Also, now that Object.observe has been removed from the standards track[2], does anyone know the fate of Array.observe? MDN says it's not on std track either.[3]

How are we going to write any sort of observable library that includes arrays with zero support from the language? (At least Objects have getters and setters and the ability to seal etc...)

[1] http://mweststrate.github.io/mobservable/refguide/observable... [2] https://esdiscuss.org/topic/an-update-on-object-observe [3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Object.observe was a bad idea. Even when it was available in chrome I didn't consider using it. However, the ES6 proposal for object proxies will hopefully become generally available as those can solve the same issue way more elegantly. Proxies will be able to address the current limitations of arrays in Mobservable.

I wrote a short blog post about the issue: https://medium.com/p/object-observe-is-dead-long-live-mobser.... Mobservable currently relies on property getters / setters, both for arrays and objects. Probably until proxies will be generally available.