Skip to content

Commit 00c2ddc

Browse files
committed
deferred.always: Added note for parameters changing order
Fixes gh-763 Closes gh-779
1 parent 5e0f6fa commit 00c2ddc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

entries/deferred.always.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<desc> Add handlers to be called when the Deferred object is either resolved or rejected. </desc>
1818
<longdesc>
1919
<p>The argument can be either a single function or an array of functions. When the Deferred is resolved or rejected, the <code>alwaysCallbacks</code> are called. Since <code>deferred.always()</code> returns the Deferred object, other methods of the Deferred object can be chained to this one, including additional <code>.always()</code> methods. When the Deferred is resolved or rejected, callbacks are executed in the order they were added, using the arguments provided to the <a href="/deferred.resolve/"><code>resolve</code></a>, <a href="/deferred.reject/"><code>reject</code></a>, <a href="/deferred.resolveWith/"><code>resolveWith</code></a> or <a href="/deferred.rejectWith/"><code>rejectWith</code></a> method calls. For more information, see the documentation for <a href="/category/deferred-object/">Deferred object</a>.</p>
20+
<p><strong>Note:</strong> The <code>deferred.always()</code> method receives the arguments that were used to <code>.resolve()</code> or <code>.reject()</code> the <code>Deferred</code> object, which are often very different. For this reason, it's best to use it only for actions that do not require inspecting the arguments. In all other cases, use explicit <a href="/deferred.done/"><code>.done()</code></a> or <a href="/deferred.fail/"><code>.fail()</code></a> handlers since the arguments will have well-known orders.</p>
2021
</longdesc>
2122
<example>
2223
<desc>Since the <a href="/jQuery.get/"><code>jQuery.get()</code></a> method returns a <code>jqXHR</code> object, which is derived from a Deferred object, we can attach a callback for both success and error using the <code>deferred.always()</code> method.</desc>

0 commit comments

Comments
 (0)