Check out a free preview of the full Ember Octane Fundamentals course

The "Tracked Properties Q&A" Lesson is part of the full, Ember Octane Fundamentals course featured in this preview video. Here's what you'd learn in this lesson:

Mike fields questions about previous versions of Ember, objects with tracked properties, and the first Ember release which includes native classes.

Preview
Close

Transcript from the "Tracked Properties Q&A" Lesson

[00:00:00]
>> Speaker 2: You used to need computed, but because the user ID is tracked, you don't need computed here.
>> Mike North: So if you've used Ember before, a lot of the stuff around computed properties and stating your dependencies and all that, completely gone away. All you need to know, all you need to think about is tracked has to be added to anything that is rendered state or observed state, which includes, if you are using computed properties this would also include that.

[00:00:28]
But if it's used in a template, or a computed property or an observer, the last two of which are sort of things I'm not talking about today, you must track it. If you're gonna change it and it's used in those contexts, you must track it.
>> Speaker 2: If you have a object passed in that has tracked properties on it, does that state of being tracked propagate?

[00:00:50]
>> Mike North: Good question. So first I want to point out that anything passed into your component is already tracked. So the object itself that you pass in, let's say it's an object that has properties first name and last name. The object itself is tracked like all args passed into a component.

[00:01:09]
And yes, the inner properties would be tracked as well. So when a property is tracked the decorator would set that object up and no matter how it’s used or where, it’s the object that is enabled for tracking with respect to that particular property. So nothing about how it’s used or where it’s used would affect that.

[00:01:37]
Any other questions?
>> Jacob: Yeah, Mike which version of Ember can you start using track properties in?
>> Mike North: Thank you. So, Jacob, the first release that you can use Ember native classes in, which is sort of part of this situation, we're looking at with polyfil that you can add, I think we go back to Ember 3.4.

[00:01:59]
Tracked properties are gonna be enabled in the first stable release of Ember Octane so today we are using a canary build but for watchers of this video in the future It's my best guess at this point. Man I'm setting myself up to be right or wrong by putting a number out on video 3.13, something like that.

[00:02:26]
So for now you have to use this canary version because this Octane is in a preview state where we're gathering feedback and enabling things. And teaching people how to use it and then once it hits the stable release, this is one of the things that will be first available without a feature flag or something at that point.

[00:02:48]
And I should point out, the reason I've mentioned native classes came earlier. It's kinda hard to get value out of using native classes without using tracked an action. You can install Ember decorators, which is a community library but it's maintained by the same people same person has his name's Chris Garrett, who has been driving a lot of this work in the framework itself.

[00:03:15]
And so that is another way to use decorators and native classes with Ember. But I would not describe that as Ember Octane. Tracked is very much a part of Ember Octane. But you can kind of get to a pretty close middle ground state with this library called Ember decorators so that is where I would look for that.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now