From 19ad0f492462385d83a1960eb94a9cc33211b6d2 Mon Sep 17 00:00:00 2001
From: Timo Tijhof
Date: Thu, 16 Mar 2017 13:31:49 -0700
Subject: [PATCH] jQuery.when: Add Thenable and Promise as acceptable types
Technically replacing Deferred with Thenable would work, but
mentioning Deferred and Promise directly should make this
easier to understand for new and existing users.
Fixes #906.
---
entries/jQuery.when.xml | 9 ++++++---
pages/Types.html | 3 +++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/entries/jQuery.when.xml b/entries/jQuery.when.xml
index 09c8393e..a27f2adc 100644
--- a/entries/jQuery.when.xml
+++ b/entries/jQuery.when.xml
@@ -3,11 +3,14 @@
jQuery.when()
1.5
-
- Zero or more Deferred objects, or plain JavaScript objects.
+
+ Zero or more Thenable objects.
+
+
+
- Provides a way to execute callback functions based on zero or more objects, usually Deferred objects that represent asynchronous events.
+ Provides a way to execute callback functions based on zero or more Thenable objects, usually Deferred objects that represent asynchronous events.
If no arguments are passed to jQuery.when(), it will return a resolved Promise.
If a single Deferred is passed to jQuery.when(), its Promise object (a subset of the Deferred methods) is returned by the method. Additional methods of the Promise object can be called to attach callbacks, such as deferred.then. When the Deferred is resolved or rejected, usually by the code that created the Deferred originally, the appropriate callbacks will be called. For example, the jqXHR object returned by jQuery.ajax() is a Promise-compatible object and can be used this way:
diff --git a/pages/Types.html b/pages/Types.html
index 47f5ea74..5eb5eceb 100644
--- a/pages/Types.html
+++ b/pages/Types.html
@@ -93,6 +93,7 @@
jQuery
XMLHttpRequest
jqXHR
+ Thenable
Deferred Object
Promise Object
Callbacks Object
@@ -657,6 +658,8 @@ XMLHttpRequest
jqXHR
As of jQuery 1.5, the $.ajax() method returns the jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the jqXHR section of the $.ajax entry
+Thenable
+Any object that has a then method.
Deferred Object
As of jQuery 1.5, the Deferred object provides a way to register multiple callbacks into self-managed callback queues, invoke callback queues as appropriate, and relay the success or failure state of any synchronous or asynchronous function.