Async JavaScript: Build More Responsive Apps with Less Code (Pragmatic Express)

Async JavaScript: Build More Responsive Apps with Less Code (Pragmatic Express)

Trevor Burnham

Language: English

Pages: 104

ISBN: 1937785270

Format: PDF / Kindle (mobi) / ePub


With the advent of HTML5, front-end MVC, and Node.js, JavaScript is ubiquitous--and still messy. This book will give you a solid foundation for managing async tasks without losing your sanity in a tangle of callbacks. It's a fast-paced guide to the most essential techniques for dealing with async behavior, including PubSub, evented models, and Promises. With these tricks up your sleeve, you'll be better prepared to manage the complexity of large web apps and deliver responsive code.

With Async JavaScript, you'll develop a deeper understanding of the JavaScript language. You'll start with a ground-up primer on the JavaScript event model--key to avoiding many of the most common mistakes JavaScripters make. From there you'll see tools and design patterns for turning that conceptual understanding into practical code.

The concepts in the book are illustrated with runnable examples drawn from both the browser and the Node.js server framework, incorporating complementary libraries including jQuery, Backbone.js, and Async.js. You'll learn how to create dynamic web pages and highly concurrent servers by mastering the art of distributing events to where they need to be handled, rather than nesting callbacks within callbacks within callbacks.

Async JavaScript will get you up and running with real web development quickly. By the time you've finished the Promises chapter, you'll be parallelizing Ajax requests or running animations in sequence. By the end of the book, you'll even know how to leverage Web Workers and AMD for JavaScript applications with cutting-edge performance. Most importantly, you'll have the knowledge you need to write async code with confidence.

What You Need:

Basic knowledge of JavaScript is recommended. If you feel that you're not up to speed, see the "Resources for Learning JavaScript" section in the preface.

Applied jQuery: Develop and Design

Android Application Development Cookbook: 93 Recipes for Building Winning Apps

The DevOps 2.0 Toolkit

The Business of Android Apps Development: Making and Marketing Apps that Succeed on Google Play, Amazon Appstore and More

Privatizing China: Socialism from Afar

 

 

 

 

 

 

 

 

 

 

 

next function in the list. This makes it easy to mix synchronous functions with async ones. The next function will receive the results of its predecessor (that is, its return value or the arguments it passed to this) or the results of all instances of its predecessor if that predecessor was run with this.parallel or this.group. (The difference is that this.parallel provides those results as separate arguments, while this.group merges them into arrays.) The entire library is, as of this

setTimeout goes something like this: Given a callback and a delay of n milliseconds, setTimeout runs that callback n milliseconds later. But as we’ll see in this section, and throughout this chapter, that description is seriously flawed. In most cases, it’s only approximately true. In others, it’s flat-out wrong. To truly understand setTimeout, we have to understand the JavaScript event model as a whole. Now or Later? To begin our exploration of setTimeout, let’s look at a simple

callback fires immediately. This unpredictable behavior can get you in a lot of trouble if you aren’t careful. One mistake I’ve seen (and made myself) is assuming that $ will run a function after other scripts on the page have loaded. ​​// application.js​​ ​​$(function() {​​ ​​ utils.log('Ready');​​ ​​});​​ ​​​​ ​​// utils.js​​ ​​window.utils = {​​ ​​ log: function() {​​ ​​ if (window.console) console.log.apply(console, arguments);​​ ​​ }​​ ​​};​​ ​​

Trevor delivers a concise guide to writing asynchronous JavaScript with a perfect balance of browser and server-side examples. Part guide, part overview, wholly engaging, this book is a must-read for any JavaScript developer looking to level up. → Wynn Netherland, co-host of The Changelog This is a complete guide to the asynchronous realm of JavaScript. The concepts and tools covered by this book are essential to anyone willing to build full-blown, well-structured and efficient JavaScript

ecosystem the language enjoys today: John Resig, for creating the browser’s de facto standard library, jQuery; Jeremy Ashkenas, for producing CoffeeScript and the rich yet minimalistic Backbone.js framework; Ryan Dahl, for giving the language a robust server environment; and all the other programmers who’ve proven through their work that JavaScript is a first-class language after all. Of course, love alone didn’t write this book. I’d like to thank the Pragmatic Bookshelf team for helping me

Download sample

Download