Icaro Temponi
08/28/2019, 7:54 PMDominaezzz
08/28/2019, 7:59 PMDominaezzz
08/28/2019, 8:00 PMIcaro Temponi
08/28/2019, 8:03 PMDominaezzz
08/28/2019, 8:04 PMonDestroy
CoroutineScope
, which I use for loading stuff.Dominaezzz
08/28/2019, 8:06 PMonStop
to cancel long running operations, like updating progress bars in the background (perhaps based on jobs from the onDestroy
scope).Dominaezzz
08/28/2019, 8:08 PMonPause
, to cancel coroutines that hold on to a resource like a wake lock, media service or audio focus to unregister them.Dominaezzz
08/28/2019, 8:09 PMonDestroy
is the most common one.Icaro Temponi
08/28/2019, 8:12 PMIcaro Temponi
08/28/2019, 8:13 PMlouiscad
08/28/2019, 8:29 PMcreateScope(activeWhile = aLifecycleState)
call. You can see its doc and implementation here: https://github.com/LouisCAD/Splitties/tree/master/modules/lifecycle-coroutinesgildor
08/29/2019, 1:45 AMfragment on backstack is stopped, not destroyed@Icaro Temponi The best scope is Fragment lifecycleScope. Fragment has 2 flavors of scopes:
fragment.lifecycleScope
- which has lifecycle of Fragmnt object
fragment.viewLifecycleOwner.lifecycleScope
- which has lifecycle of Fragment’s view and cancelled automatically on View destroy (like in case of backstack or detaching)gildor
08/29/2019, 1:47 AMand implementation hereLooks the same as existing official lifecycle-ktx extensions
Matej Drobnič
08/29/2019, 5:00 AMgildor
08/29/2019, 5:57 AMMatej Drobnič
08/29/2019, 6:20 AMigor.wojda
08/29/2019, 10:12 AM2.1.0-rc01
the lifecycle-viewmodel-ktx
exposes viewModelScope
property for ViewModel
gildor
08/29/2019, 10:25 AMigor.wojda
08/29/2019, 10:30 AMMatej Drobnič
08/29/2019, 10:43 AMMatej Drobnič
08/29/2019, 10:43 AMMatej Drobnič
08/29/2019, 10:43 AMval result = requestPermission(CAMERA)
Matej Drobnič
08/29/2019, 10:44 AMIcaro Temponi
08/29/2019, 11:09 AMIcaro Temponi
08/29/2019, 11:13 AMIcaro Temponi
08/29/2019, 11:14 AMlouiscad
08/29/2019, 12:38 PMondDestroyView
is fine here.Icaro Temponi
08/29/2019, 12:45 PMlouiscad
08/29/2019, 12:49 PMviewLifecycleOwner
default lifecycleScope
should have exactly that effect.Icaro Temponi
08/29/2019, 12:56 PM