Created
December 22, 2020 17:57
-
-
Save BetterProgramming/5e07ec1c84d589f54329147c5d233dfb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| extension DispatchQueue { | |
| static func background(delay: Double = 0.0, background: (()->Void)? = nil, completion: (() -> Void)? = nil) { | |
| DispatchQueue.main.async { | |
| background?() | |
| if let completion = completion { | |
| DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: { | |
| completion() | |
| }) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment