John O'Reilly
05/23/2022, 5:41 PMStateFlow
using stateIn
(which is called/collected from Fragment)...seemingly it work but feels like there's an issue, or at least some redundancy here but can't put my finger on why right now? (reason that's it's a suspend function instead of property is that it needs to call suspendFunctionReturningFlowB
here but probably other ways around that....)
suspend fun someFunction() = flowA.combine(suspendFunctionReturningFlowB()) { valA, valB ->
<some logic>
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null)
stateIn
etc redudant?yschimke
05/23/2022, 5:46 PMJohn O'Reilly
05/23/2022, 5:47 PMyschimke
05/23/2022, 5:47 PMJohn O'Reilly
05/23/2022, 5:49 PMsuspendFunctionReturningFlowB
returns a flow (based internally though on call to suspend function)....and that returned flow is then combined with flowAhfhbd
05/23/2022, 5:50 PMsuspendFunctionReturningFlowB
should not be suspend at all. No Flow
returning function should be marked as suspend
yschimke
05/23/2022, 5:50 PMval someVal = flowA.combine(flow { emitAll(suspendFunctionReturningFlowB()) }) { valA, valB ->
<some logic>
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null)
John O'Reilly
05/23/2022, 5:53 PMFlow
returning function should be marked as suspend"
Probably again can be done differently but that function is returning one of 2 flows based on result of call to a suspend function.yschimke
05/23/2022, 6:01 PMJohn O'Reilly
05/23/2022, 6:03 PMhfhbd
05/23/2022, 6:21 PMflow { if(suspending()) emitAll(flow1) else emitAll(flow2) }
then 🙂uli
05/24/2022, 6:04 AM