Author: Samuel WilliamsWhen: Thursday, 03 June 2010
In a comment form, you might want to send the data using AJAX to get a preview. In this case, you generally want to aggregate the events so that you only fetch a new preview when the user stops typing or a certain timeout is reached.
Here is an example of how to use it:
Here is an explanation of how it works: You create an AggregateCallback with a timeout value (in milliseconds). You call update a number of times. If you don't call update within the timeout, the callback is fired.
If you set enforce to true, the callback will be fired every timeout milliseconds, and also finally timeout milliseconds after the last call to update. This means that, in the case of a live preview, the server will be polled once every second even while the user is continuing to type.