Exposing a `suspend fun` from a nested Fragment to...
# android
g
Exposing a
suspend fun
from a nested Fragment to be called by the parent Fragment. What’d happen if the nested Fragment gets killed before the suspension point returns?
o
depends on who's calling the suspend fun, if it runs in the nested Frag context then it will be canceled, if it runs in the parent Frag context then it won't
g
It’d be called from the parent fragment. Do you know a way to simulate a Fragment being killed, without the Activity being killed?
This library is an example, it attaches a child fragment to a parent fragment and suspends for the permission results: https://github.com/sagar-viradiya/eazypermissions/blob/master/coroutinespermission/src/main/java/com/eazypermissions/coroutinespermission/PermissionManager.kt
o
the deferred is a different case
if the fragment is removed from memory, it's likely that the deferred's continuation would be removed too
thus the coroutine would never resume
s
@sagar-viradiya Q on your library above ^^