v79
11/19/2022, 9:39 AMLiveData
and the other is not? Because I think I need that.v79
11/19/2022, 9:45 AMinit { ]
block in my ViewModel, I need to fetch a fixed value from the database. Currently, the database returns a LiveData object, as I need it like that elsewhere. So I think I'm going to end up in the state where my DAO and repo has the following almost-duplicate functions:
@Query("SELECT * FROM ChargeEvent WHERE id = :id")
fun getChargeEventWithId(id: Long): LiveData<ChargeEvent?>
@Query("SELECT * FROM ChargeEvent WHERE id = :id")
fun getExistingChargeEventWithId(id: Long): ChargeEvent?
Which just looks like a code smell to me. Or rather, a lack-of-understanding smell.Michael Marshall
11/21/2022, 3:08 AMLiveData
instead?Brandon Howard
11/30/2022, 6:20 PMrattleshirt
12/14/2022, 3:00 PMFlow
and call viewModelScope.launch { flow.firstOrNull() }
from init
if you only need it once. Otherwise you could always extract the string from the query as const and reuse it in bothrattleshirt
12/14/2022, 3:03 PMsuspend fun
vs Flow