Created
February 15, 2016 07:59
-
-
Save sms-system/ed1b2395444980474273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wait = (condition, successCallback, time, timeoutCallback, frequency=250, loadingCallback) -> | |
time *= 1000 / frequency if time? | |
waiting = setInterval -> | |
if condition.call() | |
successCallback.call() | |
else if time? && --time <= 0 | |
timeoutCallback?.call() | |
else | |
loadingCallback?.call() | |
return | |
clearInterval waiting | |
, frequency |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment