From f5f253ad019ca844debd67f179e266827b8010ba Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 25 May 2018 10:56:08 +0100 Subject: [PATCH] Add an optional pollInterval parameter to waitFor --- services/web/public/coffee/ide.coffee | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 3ddf9521b6..312d528670 100644 --- a/services/web/public/coffee/ide.coffee +++ b/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"])