I am sure that the Deferred class is simply not designed to work the way you want, because they are designed for one-time use. I even sat in an entire session on Deferreds in jQueryConf, and reusing them was not even mentioned.
In addition, as you can see on the Pending API page:
http://api.jquery.com/category/deferred-object/
There is no way to restart. You may be able to manually change the Deferred properties to simulate a "reload", but in fact I think you should make your own class at the moment, since you are really looking for something Deferred does not offer.
You must remember that Deferred is designed so that you can say “hey, put it off, do something” ( new Deferred().when(something) ), and then you can say “hey, delayed when it did X” ( deferred.then(x) ). Now when you say "when is this done", i.e. when you make a .then call, Deferred can be in two states: done or not, but the call works anyway (if it resolves right away, otherwise it starts).
Now, if the Deferred can have a third state ("done but restarted"), the .then call would not know what to do: "done but restarted" means that it should start it thens or not? The answer depends on whether you called the .then call before or after the reboot call, and, as you hope, it will be quite complicated (especially if you allow several restarts).
Instead of dealing with all of this (none of which is needed for $.ajax ), the jQuery people went with the (relatively simple) current version of Deferred, and I think that was the right call on their part.
machineghost
source share