didUpdateAttrs not called on array modifications

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.

Nope. Expected behavior.

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

1 Like

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

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

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