Mastering JavaScript Promises

Discover and explore the world of promises, one of JavaScript's most powerful concepts
Preview in Mapt

Mastering JavaScript Promises

Muzzamil Hussain

1 customer reviews
Discover and explore the world of promises, one of JavaScript's most powerful concepts
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Mastering JavaScript Promises Book Cover
Mastering JavaScript Promises
$ 39.99
$ 28.00
Learning JavaScript Promises: Practical Applications in ES6 and AngularJS [Video] Book Cover
Learning JavaScript Promises: Practical Applications in ES6 and AngularJS [Video]
$ 74.99
$ 63.75
Buy 2 for $35.00
Save $79.98
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

Book Details

ISBN 139781783985500
Paperback188 pages

Book Description

JavaScript is a tool for the gurus who create highly useful applications, but it has some limitations. To overcome these limitations, a concept called JavaScript promises is rising rapidly in popularity. Promises makes writing complex logics more manageable and easy.

This book starts with an introduction to JavaScript promises and how it has evolved over time. You will learn the JavaScript asynchronous model and how JavaScript handles asynchronous programming. Next, you will explore the promises paradigm and its advantages.

Finally, this book will show you how to implement promises in platforms used in project development including WinRT, jQuery, and Node.js.

Table of Contents

Chapter 1: Promises.js
The fall and rise of JavaScript
Google's contributions to JavaScript
Where Promises.js came in?
What is a promise?
Why do we need promise in JS?
Software prerequisites
Future, promise, and delay
States of a promise
How do we keep Promises.js in this book?
Browser compatibility
Summary
Chapter 2: The JavaScript Asynchronous Model
Programming models
Learning the JavaScript asynchronous model
The mechanism of a callback function in JavaScript
The events
The publisher/subscriber
The promises object
Summing up – the asynchronous programing model
Summary
Chapter 3: The Promise Paradigm
Callback, revisited
Promise
Deferred
How do promise and deferred relate to each other?
Standard behaviors of the Promise API
Interactive promises
The states and return values of a promise
Common sequencing patterns
Decoupling events and applications logic
What promises prescribed not to do
Promises and exceptions
Best practices to handle exceptions in promise
Considerations while choosing a promise
Summary
Chapter 4: Implementing Promises
How to implement promises
Implementations in Java
Say hello to JDeferred
Mechanics of JDeferred
Ultimate JDeferred
Summary
Chapter 5: Promises in WinRT
An introduction to WinRT
The evolution of WinRT
A little detail about WinJS
WinJS – its purpose and a distribution history
HTML5, CSS3, and JavaScript
WT with HTML5, CSS3, and JavaScript
The need for integrating promise with WT
Problems when using asynchronous programming
Jumpstarting promises
Writing a function that returns a promise
Error handling
Chaining promises using the then() and done() functions
Summary
Chapter 6: Promises in Node.js
The V8 engine – the mechanics
The V8 engine in Google Chrome
The evolution of Node.js
A brief introduction to Node.js
Download and install Node.js
Node Package Manager – NPM
Choice of environment
Setting up the environment for Node.js
A simple node server
Things we learned so far
Node.js with the Q library
Moving ahead with Q
Propagation in Q
Chaining and nesting promises
Sequences in Q
Combination in Q
How to handle errors in Q in Node.js
Making progress with promises
Getting to the end of a chain of promises
Callback-based promises versus Q-based promises
Q.Promise() – another way to create promises
Static methods of Q
Promise as a proxy
Familiarizing Node.js – the Q way
Unbinds and its solution
Q support for tracing stacks
Making promise-based actions
Object handling promises
View revisited
Aborting a promise
Q utilities for Node.js
Summary
Chapter 7: Promises in Angular.js
The evolution of Angular.js
The structure of the Angular.js document
Getting started with Angular.js
Creating your first Angular.js file
How to use Angular.js on your local machine
What would be your preference for the server?
Key elements of Angular.js
Implementing promises in Angular.js
The schematics of using promises in Angular.js
Promise as a handle for callback
Blindly passing arguments and nested promises
Deferred objects or composed promises
Dealing with the nested calls
Concurrency in Angular.js
The combination of success and error
The safe approach
Route your promise
Summary
Chapter 8: Promises in jQuery
From where it started?
Behind the scenes – how does jQuery work?
Is your document ready to submit?
How to use jQuery
The syntax
Caching in jQuery
A sample example
JavaScript before and after jQuery
The solution – introducing promises in jQuery
Deferred in jQuery
$.Deferred().promise() in jQuery
Projecting a promise in jQuery
Joining promises with $.when
Your own $.Deferred process
The advent of promises in jQuery
Summary
Chapter 9: JavaScript – The Future Is Now
ECMAScript 6 (ECMA 262)
harmony:generators
The MEAN stack
Real-time communication in JavaScript
Internet of Things
Computer animation and in 3D graphics
NoSQL databases
Summary

What You Will Learn

  • Get a complete overview of the promises paradigm and its advantages
  • Discover the programming models that are used to build JavaScript
  • Execute the asynchronous programming model in JavaScript and understand its usefulness in modern web development
  • Employ promises in JavaScript to boost your project performance
  • Apply the best practices of promises in JavaScript to your platform of choice
  • Manage your JavaScript code in a more professional and maintainable manner
  • Utilize promises effectively and efficiently in different domains and disciplines of software engineering
  • Implement promises in WinRT, Node.js, jQuery, and Angular.js

Authors

Table of Contents

Chapter 1: Promises.js
The fall and rise of JavaScript
Google's contributions to JavaScript
Where Promises.js came in?
What is a promise?
Why do we need promise in JS?
Software prerequisites
Future, promise, and delay
States of a promise
How do we keep Promises.js in this book?
Browser compatibility
Summary
Chapter 2: The JavaScript Asynchronous Model
Programming models
Learning the JavaScript asynchronous model
The mechanism of a callback function in JavaScript
The events
The publisher/subscriber
The promises object
Summing up – the asynchronous programing model
Summary
Chapter 3: The Promise Paradigm
Callback, revisited
Promise
Deferred
How do promise and deferred relate to each other?
Standard behaviors of the Promise API
Interactive promises
The states and return values of a promise
Common sequencing patterns
Decoupling events and applications logic
What promises prescribed not to do
Promises and exceptions
Best practices to handle exceptions in promise
Considerations while choosing a promise
Summary
Chapter 4: Implementing Promises
How to implement promises
Implementations in Java
Say hello to JDeferred
Mechanics of JDeferred
Ultimate JDeferred
Summary
Chapter 5: Promises in WinRT
An introduction to WinRT
The evolution of WinRT
A little detail about WinJS
WinJS – its purpose and a distribution history
HTML5, CSS3, and JavaScript
WT with HTML5, CSS3, and JavaScript
The need for integrating promise with WT
Problems when using asynchronous programming
Jumpstarting promises
Writing a function that returns a promise
Error handling
Chaining promises using the then() and done() functions
Summary
Chapter 6: Promises in Node.js
The V8 engine – the mechanics
The V8 engine in Google Chrome
The evolution of Node.js
A brief introduction to Node.js
Download and install Node.js
Node Package Manager – NPM
Choice of environment
Setting up the environment for Node.js
A simple node server
Things we learned so far
Node.js with the Q library
Moving ahead with Q
Propagation in Q
Chaining and nesting promises
Sequences in Q
Combination in Q
How to handle errors in Q in Node.js
Making progress with promises
Getting to the end of a chain of promises
Callback-based promises versus Q-based promises
Q.Promise() – another way to create promises
Static methods of Q
Promise as a proxy
Familiarizing Node.js – the Q way
Unbinds and its solution
Q support for tracing stacks
Making promise-based actions
Object handling promises
View revisited
Aborting a promise
Q utilities for Node.js
Summary
Chapter 7: Promises in Angular.js
The evolution of Angular.js
The structure of the Angular.js document
Getting started with Angular.js
Creating your first Angular.js file
How to use Angular.js on your local machine
What would be your preference for the server?
Key elements of Angular.js
Implementing promises in Angular.js
The schematics of using promises in Angular.js
Promise as a handle for callback
Blindly passing arguments and nested promises
Deferred objects or composed promises
Dealing with the nested calls
Concurrency in Angular.js
The combination of success and error
The safe approach
Route your promise
Summary
Chapter 8: Promises in jQuery
From where it started?
Behind the scenes – how does jQuery work?
Is your document ready to submit?
How to use jQuery
The syntax
Caching in jQuery
A sample example
JavaScript before and after jQuery
The solution – introducing promises in jQuery
Deferred in jQuery
$.Deferred().promise() in jQuery
Projecting a promise in jQuery
Joining promises with $.when
Your own $.Deferred process
The advent of promises in jQuery
Summary
Chapter 9: JavaScript – The Future Is Now
ECMAScript 6 (ECMA 262)
harmony:generators
The MEAN stack
Real-time communication in JavaScript
Internet of Things
Computer animation and in 3D graphics
NoSQL databases
Summary

Book Details

ISBN 139781783985500
Paperback188 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Node.js Design Patterns Book Cover
Node.js Design Patterns
$ 29.99
$ 6.00
Object-Oriented JavaScript - Second Edition Book Cover
Object-Oriented JavaScript - Second Edition
$ 29.99
$ 21.00
AngularJS Web Application Development Blueprints Book Cover
AngularJS Web Application Development Blueprints
$ 29.99
$ 21.00
React.js Essentials Book Cover
React.js Essentials
$ 23.99
$ 16.80
Mastering Node.js Book Cover
Mastering Node.js
$ 29.99
$ 6.00