Tracking the Right Thing

In this lesson, you’ll learn how to track all kinds of objects using @tracked in an Ember application.

When we mark something as @tracked in a class definition, we tell Ember to recompute any values the property is used in whenever the value of the tracked property updates. If the property is an object, this doesn’t mean that all properties of the tracked object will also be tracked. Those have to be tracked individually.

In our example, storage, itself, is tracked, but we don’t change its value. We mutate the bands array, which is a property of storage, by pushing a new item into it. To make this work, we have to mark the bands array as tracked.

To do that, we’ll need to install an add-on that provides tracking for all kinds of objects, called tracked-built-ins, using the following command:

ember i tracked-built-ins

Get hands-on with 1200+ tech skills courses.