You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by GitBox <gi...@apache.org> on 2019/10/05 21:11:09 UTC

[GitHub] [wicket] martin-g commented on a change in pull request #384: WICKET-6703 replace eval with jQuery.globalEval; add suspend/notify

martin-g commented on a change in pull request #384: WICKET-6703 replace eval with jQuery.globalEval; add suspend/notify
URL: https://github.com/apache/wicket/pull/384#discussion_r331761866
 
 

 ##########
 File path: wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
 ##########
 @@ -350,6 +350,44 @@
 	 */
 	Wicket.Ajax.Call = Wicket.Class.create();
 
+	Wicket.Ajax.Call._suspended = 0;
+
+	Wicket.Ajax.Call.currentNotify = undefined;
+
+	Wicket.Ajax.Call.suspend = function () {
+		if (typeof (Wicket.Ajax.Call.currentNotify) != "function") {
+			Wicket.Log.error("Can't suspend: no evaluation in process");
+			return;
+		}
+		Wicket.Ajax.Call._suspended++;
+		var notify = Wicket.Ajax.Call.currentNotify;
+		var released = false;
+
+		return function () {
+			// release only once
+			if (released === false) {
+				released = true;
+				Wicket.Ajax.Call._suspended--;
+				if (Wicket.Ajax.Call._suspended === 0) {
+					notify();
+				}
+			}
+		}
+	};
+
+	Wicket.Ajax.Call.getFunctionsExecuterStatus = function() {
+		Wicket.Ajax.Call.currentNotify = undefined;
 
 Review comment:
   Why ?!
   This is a huge side effect here.
   Calling `getStatus()` should not unset such important state.
   Also I think `getFunctionsExecuterStatus` should not be public, i.e. it should not be possible for the application code to be able to execute it at all. It shouldn't be a member of `Call`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services