5

Looking at the new observe ES6 featues inside object, I was wondering whether Ember and ES6 are equivalent or different? Can we use the Watchjs polyfill safely with ember?

Bergi
  • 513,640
  • 108
  • 821
  • 1,164
Ankur Agarwal
  • 669
  • 6
  • 21

1 Answers1

4

Looking at the new observe ES6 featues inside object, I was wondering whether Ember and ES6 are equivalent or different?

Most definitely different. EmberJs has it own system, where every "model" (object whose properties may be observed), is wrapped in an instance of Ember.Object. The Ember.Object base class provides all the mechanisms for listening for property changes. In order to use them, all one needs to do is .get() and .set() to access and mutate its properties.

Can we use the Watchjs polyfill safely with ember?

I have not tried this before, but I would caution against it, as my educated guess is that it will not work. This is because, as mentioned above, Ember relies on getters and setters to listen for changes on object properties, not Object.observe. So even if you use this WatchJs (or any other polyfill), EmberJs app would be oblivious to the changes, because Ember.Object does not understand or use this at the moment.

bojangle
  • 623
  • 1
  • 5
  • 14