didUpdateAttrs not called on array modifications


#1

In the guide, it is said the didUpdateAttrs will be called when there is a change in the attributes used by the template.

But the hook is not called while an object is added or removed from an array.

Here is a twiddle stating it.

Correct me if I got anything wrong.


#2

Nope. Expected behavior.


#3

I brought this up on Slack not long ago, and as Gaurav0 mentions, it’s expected behavior. Here is my Twiddle about the issue but with Objects. Solution is to call .notifyPropertyChange()

https://ember-twiddle.com/f1740177799321f88eda


#4

Is that mean you called notifyPropertyChange() in Component class or other way ? then how didUpdateAttrs() works ?


#5

The other way around. Calling it outside the Component will then trigger the hook.


#6

You can make use of [arrayContentDidChange] (http://emberjs.com/api/classes/Ember.MutableArray.html#method_arrayContentDidChange) to keep track of the added and removed objects/primitive