Are there any best practices for using/calling cor...
# coroutines
m
Are there any best practices for using/calling coroutines from an Android ContentProvider? I’m thinking in terms of CoroutineScopes and contentprovider lifecycle, etc.
l
runBlocking. The scope of a ContentProvider is either a call to one of its function, or the app process depending on what you want to do.
m
Ok thanks Louis. How about the shutdown() implementation. Anything to think about there?
w
If you use
runBlocking
then there’s nothing to release in
shutdown
from what I understand
👍 2
l
From the docs (https://developer.android.com/reference/kotlin/android/content/ContentProvider#shutdown), the
shutdown
method is only ever called in unit testing. If you're unit testing your
ContentProvider
and use something other than
runBlocking
, you can cancel your custom
CoroutineScope
in this callback.
👍 1
m
How about the CancellationSignal? Instead of passing that through the suspend functions (and checking it in loops, for example), is there a better way?