Chapter 7. Persisting Data

Up until this point, in Chapter 4 through Chapter 6, we have built a relatively simple prototype Ember application. We have utilized most of Ember’s core functionality: router, routes, controllers, Handlebars templates, and views.

In this chapter, we are ready to begin preparing our Ember application for production. In doing so, we will explore Ember Data, the model class, remote persistence and RESTful web services, reusable components, and testing. There are many ways to skin this cat, but the approach that we prefer involves Ember App Kit.

So now you should follow along the commit history and companion code with a new repo.

In this repo, you will notice that functionality introduced in Chapter 4 through Chapter 6 will be included in one single commit.

Not Rolling Our Own Ajax

Given the high-level features that were laid out at the beginning of Chapter 4, the application persists the user’s interactions as activities, building a history of the search terms. We will begin with building client-side models and persisting the data to local storage. Later, we will migrate to a solution that persists the same data to a remote, RESTful data store.

In order to understand the problems we will solve with client persistence libraries, we need to first take a look at why we would want to get away from rolling our own Ajax calls. 

After all, it is possible to just use jQuery to load JSON data from a server, then use those JSON objects as models, performing ...

Get Building Web Apps with Ember.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.