dave08
11/26/2019, 1:29 PMyield()
)?gildor
11/26/2019, 1:51 PM<http://mainHandler.post|mainHandler.post> { work() }
and with immediate it will do if (isMainThread) work() else post { work() }
dave08
11/26/2019, 1:56 PMlaunch
get run before the method exits, or can such code leak?
I have a SyncAdapter that I need to use its service's lifecycleScope ongildor
11/26/2019, 2:28 PMdave08
11/26/2019, 2:29 PMlifecycleScope
with launch
gildor
11/26/2019, 2:29 PMdave08
11/26/2019, 2:30 PMoverride fun onPerformSync(
account: Account,
bundle: Bundle,
s: String,
contentProviderClient: ContentProviderClient,
syncResult: SyncResult
) = coroutineScope.launch {
syncEventTrigger.onSyncStart(context, syncResult)
.onStart { i { "Sync Started" } }
.onCompletion { i { "Sync Stopped" } }
.collect()
}.let { Unit }
LifecycleService
that provides me with a lifecycleScope
extension (from ktx)launch
gildor
11/26/2019, 2:39 PMdave08
11/26/2019, 2:45 PMlifecycleScope
automatically I think, the problem knowing whether onPerformSync exits before the work is all done...