John O'Reilly
06/13/2021, 8:54 AMJohn O'Reilly
06/13/2021, 8:56 AMsuspend fun fetchPeople(success: (List<Assignment>) -> Unit) {
val people = peopleInSpaceApi.fetchPeople().people
success(people)
}
Then XCode gives "consider using asynchronous alternative function" prompt and can then invoke like this...it blocks then until completion handler invoked.
async {
do {
print("before")
try await repository.fetchPeople(success: { people in
print(people)
self.people = people
})
print("after")
}
catch {
print("exception")
}
}
John O'Reilly
06/13/2021, 8:57 AMJohn O'Reilly
06/13/2021, 9:17 AM(void)fetchPeopleSuccess:(void (^)(NSArray<CommonAssignment *> *))success completionHandler:(void (^)(CommonKotlinUnit * _Nullable, NSError * _Nullable))completionHandler __attribute__((swift_name("fetchPeople(success:completionHandler:)")));
kenkyee
06/13/2021, 9:32 AMJohn O'Reilly
06/13/2021, 9:34 AMwithTaskCancellationHandler
) but not sure if/how we can get access to a cancellable job corresponding to the suspend function (to allow propagating the cancellation)....John O'Reilly
06/13/2021, 9:36 AMkenkyee
06/13/2021, 9:59 AMJohn O'Reilly
06/13/2021, 10:03 AM@Throws
annotation to that suspend function then you also get error callback as wellhfhbd
06/13/2021, 10:11 AMJohn O'Reilly
06/13/2021, 10:13 AMasync
function....John O'Reilly
06/13/2021, 10:34 AMwithTaskCancellationHandler
)....but running in to a few issues there still.John O'Reilly
06/13/2021, 4:41 PMhfhbd
06/16/2021, 9:31 AMJohn O'Reilly
06/16/2021, 9:34 AMRick Clephas
06/16/2021, 9:48 AM