Viktor Vostrikov
05/05/2020, 5:57 AMoctylFractal
05/05/2020, 5:58 AMexecute(coroutineScope: CoroutineScope, bitmap: Bitmap)
is the same as CoroutineScope.execute(bitmap: Bitmap)
in terms of bytecodeViktor Vostrikov
05/05/2020, 6:01 AMoctylFractal
05/05/2020, 6:01 AMViktor Vostrikov
05/05/2020, 6:02 AMoctylFractal
05/05/2020, 6:09 AMViktor Vostrikov
05/05/2020, 6:46 AMoctylFractal
05/05/2020, 6:51 AMViktor Vostrikov
05/05/2020, 6:56 AMoctylFractal
05/05/2020, 7:11 AMViktor Vostrikov
05/05/2020, 7:16 AMoctylFractal
05/05/2020, 7:23 AMcoroutineScope {}
will wait until all things started inside are completedViktor Vostrikov
05/05/2020, 7:23 AMcoroutineScope{
}
If I call this suspend fun with viewModelScope.launch{
}
that means that coroutineScope inherits viewModelScope, yes? :)octylFractal
05/05/2020, 7:23 AMViktor Vostrikov
05/05/2020, 7:24 AMoctylFractal
05/05/2020, 7:24 AMcoroutineScope {}
really knows nothing about the viewModelScope
, it will just take the current coroutineContext
+ Job(coroutineContext[Job])
and create a new scope with those elementsJob
, but it may not necessarily have anything else in common with it (such as dispatcher)Viktor Vostrikov
05/05/2020, 7:26 AMoctylFractal
05/05/2020, 7:27 AMawait
ingviewModelScope
is appropriate here) and launch
it therecoroutineScope {}
-created scope will cause your function to suspend at the end of the block until every child Job is doneViktor Vostrikov
05/05/2020, 7:29 AMoctylFractal
05/05/2020, 7:39 AMViktor Vostrikov
05/05/2020, 8:16 AM