This may sound stupid but believe me when I do `us...
# coroutines
s
This may sound stupid but believe me when I do
users.postValue(repository.getUsers(20))
, the getUsers function executes but the value isn't posted but when I do
list = repository.getUsers(20)
and then do
users.postValue(list)
it works totally fine. What's the deal here?
The data is being loaded correctly in both cases but it's not being posted to
users
livedata in the first case. Also, I'm using
viewModelScope.launch
, if it matters
i
It seems like
repository.getUsers()
should just return a
LiveData
?
s
Yeah it could but I'm trynna figure out why this is happening
Anyways I don't like to keep
LiveData
in my repository so I'm using the
liveData
builder now
i
You're probably just better off having it return a
Flow
the entire way up, then use
asLiveData()
to convert it over in your ViewModel
2
s
Yeah I guess I'll use a flow when I add network state. Don't even need LiveData since I'm using jetpack compose so I'll just observe the flow as state