This is an old revision of the document!
Web applications typically update data from servers (eg. whether, time, animations, dollar rates, thread posts). Developers have to overcome the issue of using obsolete data due to a late response of a server. For example, consider a website that shows an animation, rotation of the Earth, using several ajax requests (see below web page). If responses of ajax requests are retrieved in wrong order, the animation cannot be observed correctly. A solution could be to wait for all frames of the animation, however, this solution could delay to much the animation. A better solution is to discard the late frames to show the animation. The DiscardLate strategy discards the late responses of ajax requests (obsolete responses).
When the “activate order” button is clicked, the animation is always showed a correct flow (right to left). When the “deactivate order” button is clicked, the animation is showed a random flow. NOTE: You have to wait until a new animation to see the effect over.
The implementation follows: Toggle between the code and example
The DiscardLate strategy is implemented as a TM advice, which is a JavaScript function, that is executed every time a response of ajax request is retrieved:
var discardLate = function(jp) { if(!this.isLate(jp)){ //is obsolete this join point? jp.proceed(); this.updateCr(jp); //notifies that join point was executed. } }
Go back the the parent page web page.