Last active
March 9, 2020 09:04
-
-
Save acchou/7b4806100c588e0681381cba5f1a8859 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