Book Image

Ember.js Cookbook

By : Erik Hanchett
Book Image

Ember.js Cookbook

By: Erik Hanchett

Overview of this book

Ember.js is an open source JavaScript framework that will make you more productive. It uses common idioms and practices, making it simple to create amazing single-page applications. It also lets you create code in a modular way using the latest JavaScript features. Not only that, it has a great set of APIs to get any task done. The Ember.js community is welcoming newcomers and is ready to help you when needed. This book provides in-depth explanations on how to use the Ember.js framework to take you from beginner to expert. You’ll start with some basic topics and by the end of the book, you’ll know everything you need to know to build a fully operational Ember application. We’ll begin by explaining key points on how to use the Ember.js framework and the associated tools. You’ll learn how to effectively use Ember CLI and how to create and deploy your application. We’ll take a close look at the Ember object model and templates by examining bindings and observers. We’ll then move onto Ember components, models, and Ember Data. We’ll show you examples on how to connect to RESTful databases. Next we’ll get to grips with testing with integration and acceptance tests using QUnit. We will conclude by covering authentication, services, and Ember add-ons. We’ll explore advanced topics such as services and initializers, and how to use them together to build real-time applications.
Table of Contents (18 chapters)
Ember.js Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Understanding the functionalities of Ember Data


Ember Data uses a single data store that can be accessed throughout an application. In this example, we'll create a simple application that retrieves a list of books and displays it to the user.

Getting ready

Before we begin, we'll need to mock data for our server. Ember CLI has a built-in mock server that can handle this situation by generating a basic Express server. However, for the purposes of this recipe, we'll go ahead and use the Ember CLI Mirage add-on. It has more features and is easier to use. You can find more information about Ember CLI Mirage at https://github.com/samselikoff/ember-cli-mirage.

  1. To begin, let's create a new application:

    $ ember new BookExample
    
  2. After the application has been created, let's install the add-on:

    $ cd BookExample
    $ ember install ember-cli-mirage
    $ ember g factory book
    

    This will install the latest Bower and npm packages needed and create the book factory for Mirage.

    To make this recipe work, we'll need to...