Actually the cancellation doesn't need to be part of the delay option
if the queuesize option is at hand. By setting queuesize=1 the new
request would automatically cancel the old one.
So, I modify the proposal for the delay option to:
1. delay: Number of milliseconds before an ajax request is issued.
Delayed requests are only queued *after* the delay, so another
non-delayed request that is triggered after the delayed request can
be queued before the delayed request. Still, delayed requests block
queue space, so if the queue size is set to x and n requests
are queued (n<=x) then the queue size is reduced to x-n. Now,
if another request comes in and the queue and x-n requests are in
the queue then one delayed request is cancelled. If several requests
were delayed the request to cancel is chosen first-in-first-out.
1. delay: Number of milliseconds before an ajax request is
issued.
If another ajax request comes in before the end of the delay the
prior one is discarded. Very important one for onkeyup events in
autosuggest boxes to avoid bombing the server down.
The delay attribute causes two things to happen: delay the request, and
(potentially) cancel the request. The attribute name identifies the
former, but does not imply the latter. I think that could be confusing.
I'm also not sure that we want to tightly couple delay and cancellation.
I want to control each individually, for example, I have a use case with
an autoSuggest composite component where I add a delay to an Ajax call
that hides a listbox, and I want don't want that Ajax call cancelled if
another Ajax request comes in before the delay is over.
Perhaps two attributes? "delay" and a boolean attribute that controls
whether the request is canceled if another Ajax request comes in before
the delay expires. A good name for the second attribute would be
difficult to come up with.
Also, there's the issue of whether we want to allow only certain types
of Ajax requests (for example only requests fired by the same component)
to cause the cancellation of a previous request with a delay.