Andrew Ebling
04/15/2021, 3:40 PMsuspend
functions in Android (which get triggered from non-UI events) and you suddenly find you need a Context
to get something done (in this instance load a preference value), what are sound approaches to adopt? I understand that storing Context
references is a no-no, due to the potential to leak Activites.Adam Powell
04/15/2021, 3:45 PMZach Klippenstein (he/him) [MOD]
04/15/2021, 3:45 PMAdam Powell
04/15/2021, 3:54 PMChannel.receiveAsFlow()
) from an activity-scoped context, you're still in good shape.Adam Powell
04/15/2021, 3:56 PMChannel.receiveAsFlow
and not MutableSharedFlow
for events that must be handled exactly once. SharedFlow
creates a diffusion of responsibility that you then have to resolve elsewhere where it can be much more difficult.Andrew Ebling
04/16/2021, 6:23 AM