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
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
jQuery in Action, Third Edition
jQuery in Action, Third Edition, is a fast-paced and complete guide to jQuery, focused on the …
book
Java 17 Quick Syntax Reference: A Pocket Guide to the Java SE Language, APIs, and Library
Quickly gain the insight necessary to address a multitude of Java coding challenges using this succinct …
book
jQuery Recipes: Find Ready-Made Solutions to All Your jQuery Problems
Quickly discover solutions to common problems, best practices you can follow, and everything jQuery has to …
book
Java Enterprise Best Practices
Java developers typically go through four "stages" in mastering Java. In the first stage, they learn …