https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

rednifre

01/12/2021, 3:45 PM
So, no .forEach but more like .forLatest... or does .forEach not look into the past anyways?
z

Zach Klippenstein (he/him) [MOD]

01/12/2021, 6:39 PM
Flows are cold by default, which means that there’s no such thing as “past” before collection begins. forEach will see every element emitted by the stream each time it’s collected. For hot streams, such as MutableSharedFlow or ones backed by channels, the items emitted by the steam depend on things like the replay buffer specified on the shared flow, or what items have been sent to the channel and not received before collection begins. ForEach will see whatever gets emitted.
r

rednifre

01/13/2021, 3:53 PM
@Zach Klippenstein (he/him) [MOD] Thanks, I guess I should use MutableStateFlow instead then.
3 Views