Skip to content

Instantly share code, notes, and snippets.

@GuilhE
Last active June 24, 2021 10:16
Show Gist options
  • Save GuilhE/8e1993036ec130b8d316b547384bf964 to your computer and use it in GitHub Desktop.
Save GuilhE/8e1993036ec130b8d316b547384bf964 to your computer and use it in GitHub Desktop.
Medium article - KMM
static func createReservation() -> Future<Void, Error> {
return Future() { promise in
manager.createReservation() { response, error in
if response != nil {
promise(Result.success(()))
} else if let error = error {
promise(Result.failure(error.toAppError()))
}
}
}
}
extension KotlinThrowable {
// Creates a LocalizedError using the error message returned from KotlinThrowable
func toAppError() -> AppError {
AppError.withText(self.message ?? "")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment