The Road to Ember Data 1.0

by Kasper Tidemann

Recently, Tom Dale and Yehuda Katz co-wrote a post regarding the road to Ember Data 1.0.

I’ve been an avid user of Ember Data from the very beginning, at least since revision 4 back in the summer of 2012. Much has changed since then, resulting in code frequently breaking and heads frequently aching. But I never complained – this is the cost of quality.

We’re nearing a stable release now, bringing along with it an API freeze and the well-thought through features we’ve come to expect from the core team.

Now, the blog post is interesting because it addresses some of the pain points I’ve had to face myself working with Ember Data, namely relationships. Say we have this App.Blog record:

{
  "id": 1,
  "name: "kaspertidemann.com",
  "posts": [2]
}

… and this App.Post record:

{
  "blog_id": 1,
  "id": 2,
  "title": "The Road to Ember Data 1.0"
)

The above makes sense, right? Well, wait a minute. What if the blog in question contains thousands of posts? In that case, would it really be necessary to include every single post id in the JSON payload?

Until recently, the answer to that question was yes. But no one wants to send "posts": [2,3,4,5,6,7,8,..] over the wire when fetching an App.Blog record. That approach is doomed to play out beyond poorly.

In a project of mine, I’ve addressed this via a layer of model controllers. The controllers allow me to do filtering, client-side searching etc. With the upcoming Ember Data version 1.0, this is partly resolved with the concept of a single source of truth – hence something to look very much forward to.

Finally, relationships always being treated asynchronously is the only plausible strategy. In my model controllers, I’ve implemented a findRecord function that always returns a promise to abstract away any confusion in this regard. The final settling on asynchronous relationships is spot on.

All in all, I’m excited about Ember Data version 1.0. It’s been a bumpy ride full of ups and downs, but I’ve never doubted the eventual stabilization of the project. Good times ahead!