mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 19:04:20 +00:00
Add a waitFor
helper to the ide object
This commit is contained in:
parent
0cb5beb689
commit
3849bcfb40
1 changed files with 14 additions and 0 deletions
|
@ -229,4 +229,18 @@ define [
|
|||
ide.$scope.project.publicAccesLevel = data.newAccessLevel
|
||||
$scope.$digest()
|
||||
|
||||
ide.waitFor = (fn, callback, timeout) ->
|
||||
sleepTime = 500
|
||||
iterationLimit = Math.floor(timeout / sleepTime)
|
||||
iterations = 0
|
||||
do tryIteration = () ->
|
||||
if iterations > iterationLimit
|
||||
return
|
||||
iterations += 1
|
||||
result = fn()
|
||||
if result?
|
||||
callback(result)
|
||||
else
|
||||
setTimeout(tryIteration, sleepTime)
|
||||
|
||||
angular.bootstrap(document.body, ["SharelatexApp"])
|
||||
|
|
Loading…
Add table
Reference in a new issue