Web Core Abort operations


On many different occasions, I block out the response of a certain request that came in too late, in a user-unfriendly way. Which is why I want to be able to abort/cancel certain request.

Using TXDataWebClient.RawInvoke:

  • I'm requesting a search operation based on every typed character using the OnChange event of an input. The results are being displayed the moment the response comes in. Imagine typing something, and then immediately deleting the input completely. So, the input box is empty; there should be no results in this case. But, because the response of the search request came in after I deleted the input, I now have a result set of an unneeded and outdated request which at the same time seems like the result of SearchText = ''. So, in this case, I want to abort that operation instead of blocking the input until a response comes in, etc.

  • Or, imagine that the user holds in a certain character button, like 'o'. This results in a lot of search operations like 'oo', 'ooo','oooo','ooooo', etc. In this case, because 'ooooo' supersedes all the previous requests of the 'o' character, I want to cancel out all the requests up until 'ooooo'.

Using TWebContinousScroll (post method)

  • On a form, lets say I have 1 continous scroll and multiple buttons. Each button results in a different result along with their item templates. In the OnFetchNextPage event, based on which button is clicked, I first change the ItemTemplate property and then I send out the request. Up until this point there is no problem; you click on a button, the HTML item template is changed, a request is being made, and finally, the response values are placed into their corresponding placeholders.
    In this use-case, the user is allowed to click anywhere, whenever he/she wants. So, imagine, after clicking on one button, before the response has arrived you click on another button. In this case, the item template has changed, and a new request is made. at this point, the previous response arrives into the newer item template, thus resulting in 'undefined' in every placeholder, because the placeholders of the new item template do not match the older request response.

Is there a way in both of the scenarios to cancel/abort certain requests (perhaps there are but only I don't know about them), or does someone have a suggestion what I can do instead?

Kind regards.

There is no current way to abort the requests. In any case, you would have to hold references to all the previous requests you made, in order to abort them. I think it's easier and better if you solve that at UI side, like only performing a new request when the previous one finished, or using a timer or a button to avoid sending the filter request for every typed key.