3

What I want to know is how to do this How can an observer find out the before and after values of the observed property in Ember.js? with the last version of Ember.JS.

Now beforeObserver and observer send only 'this'(the object that is watching) and the the query. Here and example.

fooWillChange: function() {
    console.log(
      arguments.length, //2
      arguments[0] == this, //true
      arguments[1] == 'foo' //true
    );
}.observesBefore('foo'),

fooDidChange: function() {
    //exactly equal fooWillChange
}.observes('foo')

in 'foo' case I can just pick the value with get but in the case of watching a property inside of an array(like bar.@each.name) this won't work.

Community
  • 1
  • 1
Renan Tomal Fernandes
  • 10,978
  • 4
  • 48
  • 31

1 Answers1

0

For observing array changes you can use the function addArrayObserver and then override the two functions willChange and didChange to read the changes.

I have created a jsbin as an example

For more information visit this link.

guleria
  • 741
  • 2
  • 11
  • 23