Manually tracking changes
Learn how to imperatively notify downstream observers of property changes.
Summary
The notifyPropertyChange function will let observers of your array know that it has changed. This is a useful escape hatch to force templates and computed properties using your array to update.
Manually notifying property changes makes your code imperative, so it should only be used when working on problems that don't fit into Ember's ideal workflow and best practices.
import { notifyPropertyChange } from '@ember/object';
export default class MyComponent extends Component {
@action addListItem() {
this.items.push(randomCatUrl());
notifyPropertyChange(this, 'items');
}
}