Michael Langford
02/09/2022, 9:56 PMfun fetchActivities(userName:String, completion:(List<ActivityEntry>)->Unit) {}
fun fetchMoves(userName:String, completion:(List<MoveEntry>)->Unit) {}
fun fetchScores(userName:String, completion:(List<ScoreEntry>)->Unit) {}
Igor Milakovic
02/09/2022, 10:06 PMDispatchGroup
, it that helps with googling 🙂Michael Langford
02/09/2022, 10:06 PMOliver.O
02/09/2022, 10:07 PMMichael Langford
02/09/2022, 10:07 PMOliver.O
02/09/2022, 10:11 PMMichael Langford
02/09/2022, 10:12 PMOliver.O
02/09/2022, 10:12 PMMichael Langford
02/09/2022, 10:12 PMfun fetchActivities(userName:String, completion:(List<ActivityEntry>)->Unit) {
// This executes after the network request has completed.
}
Tim Oltjenbruns
02/09/2022, 10:14 PMOliver.O
02/09/2022, 10:15 PMMichael Langford
02/09/2022, 10:16 PMOliver.O
02/09/2022, 10:16 PMcallbackFlow
for more than one result.Tim Oltjenbruns
02/09/2022, 10:17 PMlistOf(
async { function1() },
async { function2() },
async { function3() }
).awaitAll()
Michael Langford
02/09/2022, 10:19 PMTim Oltjenbruns
02/09/2022, 10:20 PMMichael Langford
02/09/2022, 10:21 PMTim Oltjenbruns
02/09/2022, 10:24 PMval activitiesDeferred = async { activites() }
val movesDeferred = async { moves() }
val scoresDeferred = async { scores() }
val activities = activitiesDeferred.await()
val moves = movesDeferred.await()
val scores = scoresDeferred.await()
Michael Langford
02/09/2022, 10:25 PMTim Oltjenbruns
02/09/2022, 10:26 PMdata class FullData(
val activities: Result<List<ActivityEntry>>?,
val moves: Result<List<MoveEntry>>?,
val scores: Result<List<ScoreEntry>>?
)
Michael Langford
02/09/2022, 10:28 PMTim Oltjenbruns
02/09/2022, 10:30 PMis callbackFlow parallelizable?It can be but that depends more on the implementation of your Thread situation that happens behind the scenes. A flow can be set on the IO dispatcher which is a big threadpool. But that won’t really matter because you have your own threads inside the implementations
Michael Langford
02/09/2022, 10:31 PMval activitiesDeferred = async { activites() }
val movesDeferred = async { moves() }
val scoresDeferred = async { scores() }
val activities = activitiesDeferred.await()
val moves = movesDeferred.await()
val scores = scoresDeferred.await()
Tim Oltjenbruns
02/09/2022, 10:32 PMMichael Langford
02/09/2022, 10:33 PMTim Oltjenbruns
02/09/2022, 10:34 PMasync
block is called from.Michael Langford
02/16/2022, 2:43 PM