-
-
Save romyilano/3c9ce997e2c89ad8f0ef93c479a6f1c5 to your computer and use it in GitHub Desktop.
Playground support code for using RxSwift or any other framework that sends async events.
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
import Foundation | |
public func delay(_ delay: TimeInterval, closure: @escaping ()->()) { | |
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { | |
closure() | |
} | |
} | |
#if NOT_IN_PLAYGROUND | |
public func playgroundTimeLimit(seconds: TimeInterval) { | |
} | |
#else | |
import PlaygroundSupport | |
public func playgroundTimeLimit(seconds: TimeInterval) { | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
delay(seconds) { | |
PlaygroundPage.current.finishExecution() | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment