LiveData which publicly exposes setValue(T) and postValue(T) method.
Questions tagged [mutablelivedata]
320 questions
0
votes
1 answer
Android Observing Multiple MutableLiveData
I have an MVVM setup, with two fragments interacting via a ViewModel. My SourceFragment is updating two MutableLiveData LatLngs in the VM. My second is a MapFragment in which I am drawing a route with the two LatLng LiveData. Both fragments are…

Obbila
- 1
- 1
0
votes
1 answer
Can I use LiveData in Worker, for notifying about data change to calling fragment/activity?
I have a one background Worker which fetches list of cars from the server.The worker is started from the onCreate of a Fragment.I want the Fragment should be notified with the list of cars that are fetched by the Worker,using LiveData and…

Yogesh Katkar
- 369
- 1
- 4
- 16
0
votes
1 answer
Why Transformation.switchMap(anyLiveData) isn't fire when i change the value of "anyLiveData"
I will hope that when i call to "addPlantToGarden()" passing respect "plantId" parameter then fire the "observers" "Transformations.switchMap(plantName)" but that doesn't happen, what is the error?
private val plantName: MutableLiveData =…

Oscar Ivan
- 819
- 1
- 11
- 21
0
votes
1 answer
LiveData in view model not being set and is null
I have the following ViewModel
class MainViewModel @Inject constructor(private val mainRepository: MainRepository) : ViewModel(){
private var _user: LoggedInUser? = null
val allProjects: MutableLiveData> =…

39fredy
- 1,923
- 2
- 21
- 40
0
votes
1 answer
Dealing with inner Transformations.switchMap on a viewModel
I am loading data from an API into an adapter, when the user clicks on it, it downloads using DownloadManager, i then use a broadcaster to let my activity know the downloadId and the hyperlink (the unique identifer for room).
I have so far been…

omega_prime
- 65
- 3
- 17
0
votes
3 answers
Conflict with EditText: Watcher to the View + Observer to the MutableLiveData
I am having trouble understanding how the Fragment + ViewModel paradigm works with a View like an EditText.
It being an EditText, it's gonna obviously be modified within the View (Fragment). But I also want to be able to modify it within the…

DidacC
- 93
- 2
- 13
0
votes
1 answer
How does exposed LiveData dispatch changes when postValue is called on MutableLiveData variable?
In ViewModel :
private var _someData : MutableLiveData = MutableLiveData()
var someData: LiveData = _someData
public fun someMethod(){
_someData.postValue(true)
}
In Fragment :
viewModel.someData.observe(this, Observer {
…

Prashant Jha
- 574
- 6
- 21
0
votes
1 answer
Don't know why this error occurs, on Mutable Live data
Getting error when space is not available between LiveData = _darkMode
Does anyone know why this is occurring or is this a bug?

Breimer
- 506
- 8
- 14
0
votes
1 answer
textView is not updating while observer is running
I'm trying the LiveData and ViewModel architecture. I have a simple counter in the ViewModel which is observed on MainActivity. I am able to confirm that the data is acquired in onChanged of the observer, but the problem is the textView is not…

Nms03
- 15
- 5
0
votes
0 answers
How to Populate Multiple Object Database with Room and LiveData Android
At cloud DB (firebase or Retrofit doesn't matter.),I have multiple objects like Restaurant, menu, food, user etc. With the first initiation of App,one by one, I need the fetch them all and populate Database. I can fetch any of them alone. I saw…

yardımcı Etis
- 140
- 2
- 12
0
votes
1 answer
why we use val for LiveData in getter instead of var
I saw this code on google and I have a question about it.
in this sample they use val for viewState and use getter so if I use val I can change any thing in LiveData so using mutable live data which is created for changing items into it , but during…

Mohamad Alemi
- 13
- 1
- 7
0
votes
2 answers
LiveData - not getting data in fragment on second call
I am using LiveData to get data from the server.
In the onResume method, Calling same function every after 5 second
I am able to get data only on the First API call.
Second time the observer is not triggered and not able to get data in the…

Yogesh Nikam
- 349
- 1
- 2
- 11
0
votes
2 answers
Mutablelivedata variable instance size issue
Let's say we have the stock of items stored in the JSON txt file. To access the data we load JSON file using a stringBuilder class, then populate StokItems into:
List stock;
like this:
stock.clear();
…

Paul Paku
- 360
- 2
- 16
0
votes
1 answer
CoroutineLiveData Builder repository not being invoked
I'm trying to use the new liveData builder referenced here to retrieve my data, then transform it into view models. However, my repository code isn't being invoked (at least I'm not able to see it being triggered when I use my debugger). Am I not…

VIN
- 6,385
- 7
- 38
- 77
0
votes
1 answer
Observer for MutableLiveData not being triggered
I am developing an activity using MutableLiveData to keep my fragments up-to-date with the results retrieved from a search, but the Observer is not being triggered after the list of results is updated.
I have, on the main activity, an EditText where…

Leonardo Dias
- 335
- 5
- 20