Yuri Drigin
04/21/2021, 4:33 PMval tokens = viewModel.tokens.observeAsState(listOf())
I use mock viewModel for preview with hardcoded livedata
override val stables: LiveData<List<StableTokenWithMetaAndRate>> = liveData {
listOf(StableTokenWithMetaAndRate.USDp, StableTokenWithMetaAndRate.EURp)
}
However in the preview show me an empty list (((Zach Klippenstein (he/him) [MOD]
04/21/2021, 4:40 PMlistOf()
you’re passing to observeAsState
is the initial value, so that’s why it’s showing it in the preview. The non-interactive preview won’t run any coroutines, so observeAsState
never actually starts observing your LiveData
. At least I’m guessing that’s what it is.Yuri Drigin
04/21/2021, 4:51 PMZach Klippenstein (he/him) [MOD]
04/21/2021, 4:58 PMZach Klippenstein (he/him) [MOD]
04/21/2021, 4:59 PMState<T?>
– might be a bug, it should just be State<T>
i’d think)Dominaezzz
04/21/2021, 6:54 PMemit
in your liveData { .... }
.Albert Chang
04/21/2021, 11:57 PMnull
from LiveData<T>
.Zach Klippenstein (he/him) [MOD]
04/22/2021, 12:11 AM