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() }
gildor
11/26/2019, 1:54 PMgildor
11/26/2019, 1:55 PMgildor
11/26/2019, 1:56 PMdave08
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 ondave08
11/26/2019, 1:56 PMdave08
11/26/2019, 1:57 PMgildor
11/26/2019, 2:28 PMgildor
11/26/2019, 2:29 PMdave08
11/26/2019, 2:29 PMlifecycleScope
with launch
gildor
11/26/2019, 2:29 PMgildor
11/26/2019, 2:30 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 }
dave08
11/26/2019, 2:30 PMdave08
11/26/2019, 2:31 PMLifecycleService
that provides me with a lifecycleScope
extension (from ktx)dave08
11/26/2019, 2:32 PMlaunch
dave08
11/26/2019, 2:33 PMdave08
11/26/2019, 2:34 PMdave08
11/26/2019, 2:35 PMdave08
11/26/2019, 2:36 PMgildor
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...dave08
11/26/2019, 2:45 PMdave08
11/26/2019, 2:46 PM