Skip to content

Instantly share code, notes, and snippets.

@svetlanama
Created December 10, 2017 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svetlanama/9201b11dfc7ed7df1d2e1ebdb5580667 to your computer and use it in GitHub Desktop.
Save svetlanama/9201b11dfc7ed7df1d2e1ebdb5580667 to your computer and use it in GitHub Desktop.
Return completionCallback after completing internal callbacks
private func initView(completionCallback: (() -> ())? = nil) {
var callbacksLeft = 2
func checkCompleted() {
callbacksLeft -= 1
if callbacksLeft == 0 {
completionCallback?()
}
}
connectSocketServer() {
checkCompleted()
}
loadPrivateMessages() {
checkCompleted()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment