Cancelling previous requests on map move/new request

Discussion created by jodicross on May 5, 2014
We have a web application with various functionality for displaying and searching river network information. Sometimes when a user is moving the map around or running different definition queries, requests seem to get backed up and the map loading slows down. We've been trying to look into a way of cancelling previous requests whenever the map is moved, or a new request is sent, so that these queued-but-no-longer-needed requests won't keep loading in the background and slowing everything down.

We were thinking of somehow being able to use deferred.cancel to cancel these requests, but I don't quite know how to work deferred s into our code. I understand the concept behind them, but trying to figure out how to implement this concept into our code is a bit beyond me. Would every single request have to be made into a deferred object to then be able to cancel them? Does it even make sense to use deferred s in this case, or is there another way that someone knows for doing such a thing?