Add an optional pollInterval parameter to waitFor

This commit is contained in:
Shane Kilkelly 2018-05-25 10:56:08 +01:00
parent e33b7b1a49
commit f5f253ad01

View file

@ -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"])