Last active
August 19, 2019 11:01
-
-
Save llinardos/1b8b6f5a918a3dba997695e9de6510fc 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
func onMainDo<T>(_ firstMainBlock: @escaping () -> Void, onBackgroundDo backgroundBlock: @escaping () -> T, thenOnMainDo mainBlock: @escaping (T) -> Void) { | |
DispatchQueue.main.async { | |
firstMainBlock() | |
DispatchQueue.global(qos: .background).async { | |
let result = backgroundBlock() | |
DispatchQueue.main.async { | |
mainBlock(result) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment