Geert
04/07/2024, 8:11 AMfun <T, R> Flow<T>.foldToStateFlow(initial: R, op: (acc: R, next: T) -> R): StateFlow<R>Sam
04/07/2024, 8:27 AMrunningFold (alias scan), but it returns an ordinary flow, not a state flow. To get a state flow, you would still need to provide a coroutine scope and use an operator like stateIn to actually collect the upstream values. It's kind of a pain that runningFold and stateIn both want the initial value, though... I'm not sure what's the cleanest solution to that little conundrum.Geert
04/07/2024, 8:40 AMrunningFold was the missing link. That works for me! Thnx!