Book Image

Mastering JavaScript Promises

Book Image

Mastering JavaScript Promises

Overview of this book

Table of Contents (16 chapters)
Mastering JavaScript Promises
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Mechanics of JDeferred


Coming back to our core discussion of JDeferred, there is almost everything that this implementation has adopted from promises and considered to be more promised than any other library. We will look at what the features it's providing are, and how they are implemented within.

Features of JDeferred

The implementation of JDeferred provides all the methods needed to present the promise paradigm in Java. This has features such as deferred objects and promise, promise callbacks, multiple promises, callable and runnable methods, and Java's generic support.

The following table summarizes the features, along with their available implementation:

Feature

Available implementation

Deferred object and promise

N/A

Promise callbacks

.then(…)

.done(…)

.fail(…)

.progress(…)

.always(…)

Multiple promises

.when(p1, p2, p3, …).then(…)

Callable and runnable wrappers

.when(new Runnable() {…})

Java generic support

Deferred<Integer, Exception, Double> deferred...