-
-
Save GuilhE/829c8a3321282158d0ff6d932d617eb8 to your computer and use it in GitHub Desktop.
Medium article - KMM
This file contains 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
//void example | |
static func createReservation() -> Future<Void, Error> { | |
return Future() { promise in | |
manager.createReservation() { data, error in | |
if data?.isSuccess == true { | |
promise(Result.success(())) | |
} else if let error = data?.exception { | |
promise(Result.failure(error.toAppError())) | |
} | |
} | |
} | |
} | |
//value example | |
static func fetchReservations() -> Future<[shared.Event], Error> { | |
return Future() { promise in | |
manager.reservations() { data, _ in | |
if let success = data?.data { | |
promise(Result.success(success as! [shared.Event])) | |
} else if let error = data?.exception { | |
promise(Result.failure(error.toAppError())) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment