Book description
Discover and explore the world of promises, one of JavaScript's most powerful concepts
In Detail
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.
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 developmen
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
Publisher resources
Table of contents
-
Mastering JavaScript Promises
- Table of Contents
- Mastering JavaScript Promises
- Credits
- About the Author
- About the Reviewers
- www.PacktPub.com
- Preface
- 1. Promises.js
- 2. The JavaScript Asynchronous Model
-
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
- 4. Implementing Promises
-
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
-
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
-
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
-
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
- 9. JavaScript – The Future Is Now
- Index
Product information
- Title: Mastering JavaScript Promises
- Author(s):
- Release date: July 2015
- Publisher(s): Packt Publishing
- ISBN: 9781783985500
You might also like
book
Modern Software Engineering: Doing What Works to Build Better Software Faster
Improve Your Creativity, Effectiveness, and Ultimately, Your Code In Modern Software Engineering, continuous delivery pioneer David …
book
Refactoring: Improving the Design of Existing Code
Fully Revised and Updated–Includes New Refactorings and Code Examples “Any fool can write code that a …
video
React - The Complete Guide (Includes Hooks, React Router, and Redux) - Second Edition
**This course is now updated for the latest version of React—React 18** React.js is the most …
book
Clean Code: A Handbook of Agile Software Craftsmanship
Even bad code can function. But if code isn’t clean, it can bring a development organization …