Skip to content

Instantly share code, notes, and snippets.

@cjndubisi
Created February 10, 2017 08:36
Show Gist options
  • Select an option

  • Save cjndubisi/a08464e71ebee53dc99fe021f866c90d to your computer and use it in GitHub Desktop.

Select an option

Save cjndubisi/a08464e71ebee53dc99fe021f866c90d to your computer and use it in GitHub Desktop.
Nested Callbacks.
func createProfile(completionHandler: @escaping (Any?, Error?) -> Void) {
let params = self.params()
// sign up
auth.signup(with: params) { error in
guard error == nil else { completionHandler(nil, error); return }
// log in
self.auth.signIn(email: email, password: password, completion: { (error) in
guard error == nil else { completionHandler(nil, error); return }
// get users profile
self.auth.user(with: params, completion: { (error, individual) in
guard error == nil else { completionHandler(nil, error); return }
completionHandler(individual, nil)
})
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment