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

Ayoub

07/09/2020, 2:30 PM
Hello, is there a way to declare a stateFlow without an initial value ?
z

Zach Klippenstein (he/him) [MOD]

07/09/2020, 2:31 PM
Nope. The contract of
StateFlow
is that it always must have a value.
That initial value can be
null
though if your state type is otherwise non-nullable.
👍 5
g

gildor

07/09/2020, 3:18 PM
You also can apply filterNonNull() operator, so consumer will receive only non null values and only when it initialized
👍 7
5 Views