Is there an equivalent to `LiveData builder` in fl...
# coroutines
a
Is there an equivalent to
LiveData builder
in flow?
j
I'm not very familiar with
LiveData
(I haven't done Android development in years), but there is a builder for flows as well, such as:
Copy code
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).
a
the
liveData {}
builder was modeled after kotlinx.coroutines'
flow {}
and
channelFlow {}
builders, so yes. 🙂