mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add an optional pollInterval parameter to waitFor
This commit is contained in:
parent
e33b7b1a49
commit
f5f253ad01
1 changed files with 4 additions and 5 deletions
|
@ -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"])
|
||||
|
|
Loading…
Reference in a new issue