Transcript

When I first started researching this episode, I was looking into all these different properties which were seemingly related, but on the surface it was difficult to tell how.

So all these is xproperties are telling you something about the state of the model, of the data that you’re working with. And turns out there’s a private property called the currentState , and there are a select number of states that it can be in that are in a specific hierarchy. So we’re going to go over the hierarchy today and how it demonstrates to all of these properties.

To help us do that, I’ve built a demonstration. This demonstration, it has all these, and it maps out which flags are true in which state. You can find this demonstration at this address and go over it yourself. The rest of this presentation will be pointing out patterns that I’ve noticed.

So here’s some obvious things. isDeleted is only true in the deleted branch of the hierarchy. isDirty is true in a surprising number of places. Basically it’s not dirty, this is easier to say. It’s not dirty if it’s empty, if it’s loading, if it’s loaded and saved, or if it’s deleted and saved. Everything else, dirty. Empty is just an empty state. isLoading is just in a loading state. isLoaded is everything else. And so isEmpty , isLoaded and isLoading form a set that is... it covers everything except root and it doesn’t overlap at all.

isNew , unsurprisingly, it’s in the created state and its children, might also be the invalid here, I’m not sure. By the way, if any of you are heavily involved with Ember data core and you see a problem here, go ahead and shoot me an e-mail and/or a pull request and I will correct this.

isSaving is only true in the various inFlight states, and isValid is true everywhere except where it’s explicitly not true.

There’s some other things that are also affected by the state. For example, the dirtyType can be created, updated, or deleted. And you can guess, the dirtyType will be deleted here, created here, and updated here.

Of course a model doesn’t stay in one state. It transitions to other states. This happens at the most direct level through the transitionTo . That’s a private method. Don’t use it. Notice it disappears when I uncheck ‘Private’. And this transitionTo is usually called by one of the events, which are public methods. And these usually get called by the internal model or something like that.

Anyway, there’s a lot there and I’m not going to cover all of it in this episode. Just if you’re wanting to dig really deep, that’s a good place to start for transitions.