From 5349e3c5a60dcb05842729542153822edbf6c450 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 18 Jan 2012 11:04:52 +0200 Subject: [PATCH] Defer sending of changes from client to server to group them. --- .../gwt/client/ApplicationConnection.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index f8ca0a6959..af3fcefaf2 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -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 -- 2.39.5