LiveData which publicly exposes setValue(T) and postValue(T) method.
Questions tagged [mutablelivedata]
320 questions
3
votes
1 answer
Why livedata is not notifying activity for every update happens in data
I am developing app using MVVM pattern, Retrofit, and Rx Java. The app is showing library branches and the books available there. When the activity start, I start loading all the branches, and then for every branch, I load it books. something like…

Abeer
- 31
- 2
3
votes
1 answer
Android ViewModel Observe MutableLiveData>
I have a tablayout inside a fragment. The tab layout has 3 tabs. Which tab has a fragment.
And, in the first fragment I insert a string and add it to a viewModel MutableLiveData> variable.
Then, I want to observe in the third…

Hernâni Pereira
- 312
- 4
- 19
3
votes
1 answer
Cannot observe LiveData> from ViewModel in my fragment
MyFragment.kt:
viewModel.studentsTemp.observe(this, Observer {
adapter.submitList(it)
})
MyViewModel.kt
private var _studentsTemp = MutableLiveData>()
val studentsTemp: LiveData> get() =…

Ahmad Jamal Mughal
- 89
- 1
- 8
3
votes
1 answer
How to use multiple viewmodels in single fragment in Android?
Let's say I have DashboadFragment which has its own ViewModel named DashboadViewModel. I have created separate layout for AutoCompleteTextView which is included in fragment_dashboard.xml file. I have created separate ViewModel for…

Malay
- 71
- 9
3
votes
2 answers
Dynamic parameters in viewmodel Android
How can I reuse the parameter of a ViewModel in Android? I have a recycle viewer filled with data from a database based on a parameter: selectedDate. How can I reuse it in a fragment, in this way to refresh the recycle viewer? So far I'm using a…

Erjon
- 923
- 2
- 7
- 32
3
votes
4 answers
How to observe data from live data android on Three different Fragment
I have my Activity MainActivity.kt .
And and one ViewModel MainActivityViewModel.kt
And I want to observe my live data to my 3 different fragments.
class MainActivity{
lateinit var mainActivityViewModel: MainActivityViewModel
…

Hello world
- 80
- 1
- 10
3
votes
0 answers
How to constantly update livedata object from a service with viewmodel in MVVM?
I am trying to constantly update the UI based on a long-running service output.
Basically, I want to display and append a list of users one by one after they get processed by the bound service.
MainActivityViewModel
public class…

ketan Gaikwad
- 31
- 4
3
votes
1 answer
How does observed livedata with a backing property of mutablelivedata know to trigger observers when never directly updated?
I am following the google android project "guess it" through udacity where they introduce livedata and mutablelivedata. We've got to the point where we're creating a livedata equivalent to a mutablelivedata object and creating a get()…

misterbee180
- 325
- 1
- 13
3
votes
1 answer
Fragment not receiving LiveData updates after remove + add
I am currently playing around to get a hang of the fragment's lifecycle in relation to ViewModel and LiveData.
I have 2 fragments, fragmentA and fragmentB.
I add the Observer in the onCreate method of each fragment.
@Override
public void…

Florian Walther
- 6,237
- 5
- 46
- 104
3
votes
3 answers
MutableLivedata observer triggering
I have a question about MutableLiveData in Viewmodel. Does just setValue function of MutableLiveData trigger observation? If we change content of MutableLiveData witout setValue, may it be triggered?

ahmetvefa53
- 581
- 6
- 20
3
votes
1 answer
How to cache data during 30 minutes using LiveData + Retrofit?
I am following the Android guide for using LiveData: https://developer.android.com/jetpack/docs/guide, I can make calls and get a list of objects back, but I don't understand how I could cache that list of objects, on the example I am not really…

lulu666
- 99
- 1
- 12
2
votes
1 answer
My live data is getting updated but doesn't trigger the observer in android kotlin
I have a livedata variable which I keep listening from my main activity for possible changes to do some operations in the UI thread, but unfortunately it isn't getting triggered. And please note the method test() is being called from the Javascript…

SHA
- 81
- 6
2
votes
2 answers
two-way data-binding for edit-text, and LiveData ViewModel Class
I have a question about two-way data binidng implemented by MutableLiveData in ViewModel Class for and EditText.
If I define a LoginViewModel Class for a user, which is consisted of User, email and password as follows:
class LoginViewModel :…

Parissa Kalaee
- 606
- 1
- 9
- 17
2
votes
1 answer
How to mock LiveData in mockk kotlin
Hey I am using mockk library in my project. I am trying to mock MutableLiveData, but it always give me null value. Can someone guide me how to do in proper way.
Suppose I have one function
var dataLiveData = MutableLiveData()
val…

Kotlin Learner
- 3,995
- 6
- 47
- 127
2
votes
0 answers
Why setValue() method of MutableLiveData is called from Main Thread only
I have seen at many places that setValue() should be called from MainThread but never got an explanation why?
Can anyone explain the reason under the hood?

Vivek Pratap Singh
- 1,564
- 16
- 26