Просмотр исходного кода

Add an optional pollInterval parameter to waitFor

Shane Kilkelly 8 лет назад
Родитель
Сommit
f5f253ad01
1 измененных файлов с 4 добавлено и 5 удалено
  1. 4 5
      services/web/public/coffee/ide.coffee

+ 4 - 5
services/web/public/coffee/ide.coffee

@@ -229,18 +229,17 @@ define [
 				ide.$scope.project.publicAccesLevel = data.newAccessLevel
 				$scope.$digest()
 
-		ide.waitFor = (fn, callback, timeout) ->
-			sleepTime = 500
-			iterationLimit = Math.floor(timeout / sleepTime)
+		ide.waitFor = (testFunction, callback, timeout, pollInterval=500) ->
+			iterationLimit = Math.floor(timeout / pollInterval)
 			iterations = 0
 			do tryIteration = () ->
 				if iterations > iterationLimit
 					return
 				iterations += 1
-				result = fn()
+				result = testFunction()
 				if result?
 					callback(result)
 				else
-					setTimeout(tryIteration, sleepTime)
+					setTimeout(tryIteration, pollInterval)
 
 	angular.bootstrap(document.body, ["SharelatexApp"])