Deliver Audacious Web Apps with Ember 2
by Matthew White
Version: P1.0 (October 2015)
Copyright 2015 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Dave & Andy.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
The team that produced this book includes:
Katharine Dvorak (editor)
Potomac Indexing, LLC (indexer)
Liz Welch (copyeditor)
Dave Thomas (typesetter)
Janet Furlow (producer)
Ellie Callahan (support)
For international rights, please contact .
For the Best Reading Experience...
We strongly recommend that you read this book with the publisher defaults setting enabled for your reading device or application. Certain formats and characters may not display correctly without this setting. Please refer to the instructions for your reader on how to enable the publisher defaults setting.
Table of Contents
Copyright 2015, The Pragmatic Bookshelf.
Early praise for Deliver Audacious Web Apps with Ember 2
Deliver Audacious Web Apps with Ember 2 provides a clear and thorough introduction to the powerful and elegant Ember framework. Developers looking to learn Ember or level up their Ember skills should read this book.
Nell Shamrell-Harrington |
Software development engineer, Chef |
Ember brought back the fun of Rails, this time for single-page applications with great performance.
Federico Tomassetti |
Software engineer |
If youre considering Ember for your next JavaScript project, buy this book. I felt like Id leveled up after every chapter.
Stephen Orr |
Senior software engineer, Impact Applications |
Acknowledgments
Every book is the result of a lot of behind-the-scenes effort, particularly if that book was written by a first-time author. The following people were very helpful to me in creating this book.
To the Ember core team and the Ember community: Thank you for making a product that was fun to learn and to write about. The web is better off because you volunteered your time. Thank you!
To my technical reviewers, Alessandro Bahgat, Jacob Chae, Javier Collado, Jeremy Frens, Kenneth Geisshirt, Alexander Henry, Eric Hung, Jan Nonnen, Stephen Orr, Shreerang Patwardhan, Martijn Reuvers, Brian Schau, Nell Shamrell-Harrington, Tibor Simic, Charley Stran, Federico Tomassetti, Paul Waring, Nick Watts, and Stephen Wolff: Thank you for lending your time and expertise to this project. Your comments made this a much better book than I would have written alone.
To The Pragmatic Bookshelf, including Andy Hunt, Dave Thomas, Susannah Davidson Pfalzer, Janet Furlow, and anyone else who had a hand in production: You helped me shape this into something I hope we can all be proud to have our names on.
To my editor, Katharine Dvorak: This is as much your book as mine. Your guidance and vision were so helpful to me, and without them, this book would be twice as long with half as much useful information. I cant wait to start on the next book!
To my good friend and fellow author, Sharone Williams: Thank you for commiserating with me over deadline-induced delusions. It was immeasurably helpful knowing you were also out there in the word mines.
To my parents: Thank you for all the sacrifices you made for me, and for teaching me to work hard and try new things. I hope youre as proud of this book as I am.
Most important, to my wife and son: Your patience, support, and love mean everything to me, and I would have neither started nor finished this book without you. Thank you for everything!
Matt White
October, 2015
Copyright 2015, The Pragmatic Bookshelf.
Introduction: Why Ember?
When you think about writing a web app, what excites you most? Do you look forward to writing framework code, or delivering features to your users? If youre like me, the features are the exciting stuff, and the framework exists to serve the features. Now, imagine if a group of developers had gone looking for best practices in creating a web app front end, and then codified what they found into a framework. Imagine if instead of worrying about writing glue code, you could spend your time on the exciting stuff. How would your work be different?
Ember is an open source JavaScript framework, maintained at that speeds the development of web apps. It provides much of the front-end infrastructure you need so that you can spend your time making a great app. If you use Ember, youll write less code and youll write simpler code. And simpler code is better code. By injecting object-oriented design principles into JavaScript to help you structure your code in a sensible way, Ember lets you think at a modular level. This makes your app easier to create and to maintain.
In this book, youll learn how to create audacious web apps and do so efficiently by letting Ember do the heavy lifting. Youll use Embers routing system to build single-page apps with rich interfaces and simple, shareable URLs. Youll create reusable UI components and templates and compose them into highly usable, sophisticated apps. Youll use Ember Data to read and write to RESTful services. Youll learn to use Ember addons to share code and use code others have shared. And youll learn to use Ember CLI and QUnit to organize, build, and test your apps.
What This Book Is, and Isnt
This book is a brisk introduction to the core features of Ember 2, Ember Data, and Ember CLI. These features rely on Node.js, npm, and Handlebars, but we wont go into detail on these dependencies.
This book is not an exhaustive reference on Ember, Ember Data, or Ember CLI. I hope youll learn enough to pique your curiosity, but we wont cover every last Ember API. This book is also not an introduction to JavaScript or to web development. I assume you have some knowledge of JavaScript, DOM, Ajax, HTML/CSS, and RESTful services.
Who Should Read This Book?
This book is intended for web developers who are new to Ember. If youve used other frameworks such as React or AngularJS, or if youve used jQuery, some of the ideas behind Ember should be familiar to you, but if not, you should be fine.