Book description
Orchestrating asynchronous function calls in JavaScript often leads to callback hell, but there is a reliable way to avoid this painful state of affairs. With this concise and simple guide, you’ll learn how to use jQuery deferreds and promises, an elegant approach for managing asynchronous calls in both client and server applications.
This book contains 18 examples that use deferreds to solve progressively challenging real-world programming problems, along with 75 stimulating puzzles (and their solutions) that will help you understand how and when to use deferreds. Experienced JavaScript programmers will learn new tricks in a fun way, and become immersed in the practice of event-based programming.
- Understand the logic behind creating deferreds and returning promises
- Get a structured explanation of jQuery’s deferred API
- Delve into the dynamics of using deferreds
- Explore a broad collection of useful deferred recipes developed by the authors
- Gain hands-on experience by solving challenges that accompany each recipe
- Go deeper into deferreds: encounter novel abstractions and mind-bending use cases
Publisher resources
Table of contents
- Preface
- 1. Introduction
- 2. The jQuery Deferred API
-
3. Deferred Recipes
- A Replacement for the setTimeout Function
- Messaging in Chrome Extensions
- Accessing Chrome Local Storage
- Running Promise-Returning Functions One by One
- A Promise Pool with an emptyPromise Method
- Displaying Google Maps
- Communicating with a Web Worker
- Using Web Sockets
- Automatically Retrying Failing Deferred Calls
- Memoization
- Short-Term Memoization of In-Progress Function Calls
- Streaming Promise Events
- Getting the First Result from a Set of Promises
- A Deferred Queue
- when2: An Improved jQuery.when
- Timing Out Promises
- Controlling Your Own Destiny
- Deactivating a Promise
- 4. More Time in the Mental Gymnasium
-
A. Hints for Selected Challenges
- A Replacement for the setTimeout Function
- Messaging in Chrome Extensions
- Accessing Chrome Local Storage
- Running Promise-Returning Functions One by One
- A Promise Pool with an emptyPromise Method
- Displaying Google Maps
- Communicating with a Web Worker
- Using Web Sockets
- Automatically Retrying Failing Deferred Calls
- Memoization
- Short-Term Memoization of In-Progress Function Calls
- Streaming Promise Events
- Getting the First Result from a Set of Promises
- A Deferred Queue
- when2: An Improved jQuery.when
- Timing Out Promises
- Controlling Your Own Destiny
- Deactivating a Promise
- B. The Promises/A+ Specification
- C. Converting an ArrayBuffer to Base 64
- Colophon
- Copyright
Product information
- Title: Learning jQuery Deferreds
- Author(s):
- Release date: December 2013
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449369354
You might also like
book
CSS Mastery: Advanced Web Standards Solutions
The Internet abounds with information on CSS based design. However it's spread across a large and …
book
CSS3 For Web Designers, Second Edition
foreword by JEFFREY ZELDMAN From advanced selectors to generated content to web fonts, and from gradients, …
book
jQuery in Action, Third Edition
jQuery in Action, Third Edition, is a fast-paced and complete guide to jQuery, focused on the …
book
From Arsenic to Zirconium
Indulge your love of the periodic table with this collection of poems and fun facts about …