dimsuz
01/27/2020, 10:24 PMlaunch like so:
myScope.launch {
suspendingFunction1()
someFlow
.onEach { suspendingFunction2() }
.collect {
someChannel.send(Unit) // 'send' is also a suspending fun
}
}
Will each of them block? (inside this coroutine)octylFractal
01/27/2020, 10:27 PMZach Klippenstein (he/him) [MOD]
01/27/2020, 10:40 PMsuspendingFunction1() suspends
2. suspendingFunction1() resumes
3. someFlow.onEach (returns a Flow)
4. collect suspends
5. someFlow emits
6. suspendingFunction2() suspends
7. suspendingFunction2() resumes
8. someChannel.send suspends
9. someChannel.send resumes
10. Repeat 5-9 until someFlow completes
11. collect resumesdimsuz
01/27/2020, 10:55 PMwhat you would expect other wise?4I forgot to mention this might be a silly question, I'm starting to learn this and my understanding hasn't yet formed a good mental model of how everything behaves... zachklipp This is awesome, thank you very much, just what I've needed. I think I might think of each
suspend function in terms of continuation (which I now recall it actually is). Whenever I see a call to suspend function I may translate everything after a call to it as a continuation to be called when body of said function will complete executing on current Dispatcher.Zach Klippenstein (he/him) [MOD]
01/27/2020, 11:57 PM