I'm trying to understand $.when
, and I can see that it can be useful when you want to wait for multiple deferreds before proceeding. However, I'm not sure I understand what the use-case is for using $.when
with one deferred. To illustrate:
var deferred = $.Deferred();
// Is this ever useful?
$.when(deferred).then(...)
// Or can I always do this?
deferred.then(...)
A single-premium deferred annuity (SPDA) is an annuity established with a single payment featuring investment growth solely during the accumulation phase. That growth occurs on a tax-deferred basis until annuitization, at which time regular payments will begin.
How soon can the benefit payments begin with a deferred annuity? Typically, payments can start as soon as two years after the policy issue date.
A deferred compensation plan withholds a portion of an employee's pay until a specified date, usually retirement. The lump sum owed to an employee in this type of plan is paid out on that date. Examples of deferred compensation plans include pensions, 401(k) retirement plans, and employee stock options.
Term Deferred Annuities A term deferred annuity is one that eventually turns your balance into a set number of payments, like over five years or 20 years. If you die during the term, the payments continue to your heirs. Once the term ends, though, the payments stop, even if you're still alive.
From the $.when
[docs] documentation:
If a single Deferred is passed to
jQuery.when
, its Promise object (a subset of the Deferred methods) is returned by the method.
So $.when(deferred).then(...)
is the same as deferred.promise().then(...)
.
The promise object is just a limited interface to the deferred object. It allows to add callbacks, but not to change the state of the Deferred (resolve, reject it).
So conclusively, there is basically no difference between using $.when
and calling .then
directly on the deferred object.
I don't think it makes sense to pass a single deferred object explicitly to $.when
, since you don't get any advantage. However, there might be situations where you have an unknown number of deferred objects, which means it could also be only one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With