-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make Promise without returned value? #37
Comments
Hi Alex, I imagine private func updateName(_ name: String) -> Promise<Type> {
return wrap(on: .global(qos: .default)) { handler in
guard let userID = UserRealmManager().getUser()?.id else { throw CustomError }
let ref = Database.database().reference().child(UsersPaths.Main.users.rawValue).child(userID)
ref.updateChildValues([UsersPaths.UserProperties.displayName.rawValue : userID], handler)
}
} Where the If you'd like to use return wrap { handler in
//...
}.then { _ in () } Where |
Hi @shoumikhin Thank you very much for your detailed answer. I make all network logic in the background thread. |
Hi @alexanderkhitev and @shoumikhin, I use
@discardableResult func logOut() -> Promise<Void> {
// Clear local storage
return client.request(EXPIRE_TOKEN_API_ENDPOINT)
}
// Somewhere in code
loginService.logOut()
or:
loginService.logOut().then ..... |
Hi @alexanderkhitev, I've updated the answer above. Since Thanks. |
Hello! Great framework! Please tell me how to do Promise without a return value? For example, I update the user name in firebase and I expect some value, but only check for an error. I now write Bool as a return value, although in fact I do not need it, how can this be done differently?
I would also like to know what is better to fix in this code for a more productive / readable code using the Promise framework. Thanks.
Sample code
The text was updated successfully, but these errors were encountered: