AmrJyniat
11/15/2021, 3:44 PMLiveData builder
in flow?Joffrey
11/15/2021, 3:48 PMLiveData
(I haven't done Android development in years), but there is a builder for flows as well, such as:
flow {
// suspend calls are OK here
delay(100)
emit(42)
}
Now LiveData
seems to be more an equivalent for a StateFlow
than a regular cold Flow
that this builder would create. But you can always use stateIn()
to convert your cold flow into a state flow (that will require an initial value though).Adam Powell
11/15/2021, 5:42 PMliveData {}
builder was modeled after kotlinx.coroutines' flow {}
and channelFlow {}
builders, so yes. 🙂