I'd like to ask about scope cancelation. Is it 100% synchronous?
someOtherPlace {
someUserScope.launch {
val userFlow: Flow<User?> = userDao.user()
userFlow
.collect {
// can 'it' be null here?
}
}
}
fun logout() {
allUserCoroutineScopes.forEach { it.cancel() }
userDao.deleteUser() // btw this is blocking
}
lets assume someUserScope is in the allUserCoroutineScopes list, and I'll only delete user after running the cancelation forEach
Is there a way the flow at the top will emit null? Should never happen, right? Is it safe to !! there? (I'm looking at sources but its non obvious to me)
Rx checks for disposal so it never emits once disposed. Is this the case with coroutines Flow?