This is an old revision of the document!
Web applications typically update data from servers (eg. whether, time, streaming media, 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 streaming media using several ajax requests. If responses of ajax requests are retrieved in wrong order, the streaming media cannot be observed correctly. A solution could be to wait for all frames, however, this solution could delay to much the streaming media. 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). As an example, we present below a streaming media about the rotation of the Earth (the streaming media is finite by simplicity). This example shows the effects that reproduce in a streaming media when frames in a random order.
When the “activate order” button is clicked, the streaming media is always showed a correct flow (right to left). When the “deactivate order” button is clicked, the streaming media is showed a random flow. NOTE: You have to wait until a new streaming media 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.