]> source.dussan.org Git - vaadin-framework.git/commitdiff
Defer sending of changes from client to server to group them.
authorHenri Sara <hesara@vaadin.com>
Wed, 18 Jan 2012 09:04:52 +0000 (11:04 +0200)
committerHenri Sara <hesara@vaadin.com>
Wed, 25 Jan 2012 11:20:54 +0000 (13:20 +0200)
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java

index f8ca0a6959c3ff0730b0d0e1411fc9d15b78c8c5..af3fcefaf25df37838e52f53062df9ada8f53cad 100644 (file)
@@ -17,6 +17,7 @@ import com.google.gwt.core.client.JavaScriptObject;
 import com.google.gwt.core.client.JsArray;
 import com.google.gwt.core.client.JsArrayString;
 import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.http.client.Request;
 import com.google.gwt.http.client.RequestBuilder;
 import com.google.gwt.http.client.RequestCallback;
@@ -1133,8 +1134,23 @@ public class ApplicationConnection {
      * "burst" to queue that will be purged after current request is handled.
      * 
      */
-    @SuppressWarnings("unchecked")
     public void sendPendingVariableChanges() {
+        if (!deferedSendPending) {
+            deferedSendPending = true;
+            Scheduler.get().scheduleDeferred(sendPendingCommand);
+        }
+    }
+
+    private final ScheduledCommand sendPendingCommand = new ScheduledCommand() {
+        public void execute() {
+            deferedSendPending = false;
+            doSendPendingVariableChanges();
+        }
+    };
+    private boolean deferedSendPending = false;
+
+    @SuppressWarnings("unchecked")
+    private void doSendPendingVariableChanges() {
         if (applicationRunning) {
             if (hasActiveRequest()) {
                 // skip empty queues if there are pending bursts to be sent