android-livedata Questions

6

Solved

I found that the LiveData returned by Dao will call its observer whenever the row is updated in DB, even if the LiveData value is obviously not changed. Consider a situation like the following exa...
Hydrostat asked 10/11, 2017 at 4:24

3

Solved

How to collect two state flow in activity? Because mine only the first flow that consumed. For example, inside viewmodel is like this: class ExampleViewModel: ViewModel(){ private val state = Muta...
Cloutier asked 25/5, 2021 at 13:46

11

Solved

There are two ways that make change value of MutableLiveData. But what is difference between setValue() & postValue() in MutableLiveData. I could not find documentation for same. Here is clas...
Marniemaro asked 12/7, 2018 at 7:27

1

Solved

I am getting a IllegalStateException when observing a LiveData from view model as state within Activity onCreate. Its complaining about missing lifecycle owner, however as per my understanding obse...

16

Solved

What is the difference between those 2 methods of the LiveData class? The official doc and tutorial are pretty vague on that. In the map() method the first parameter called source but in the switch...
Mauchi asked 30/11, 2017 at 14:36

7

Solved

I am trying to understand ViewModel and LiveData concepts in android. I am making a practice project but when i added implementation 'androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1' line ...

14

Solved

I have next use case: User comes to registration form, enters name, email and password and clicks on register button. After that system needs to check if email is taken or not and based on that sho...

3

I am new to kotlin and jetpack, I am requested to handle errors (exceptions) coming from the PagingData, I am not allowed to use Flow, I am only allowed to use LiveData. This is the Repository: ...

18

Solved

Is it possible to prevent LiveData receive the last value when start observing? I am considering to use LiveData as events. For example events like show message, a navigation event or a dialog tri...

2

I am following MVVM architecture for my app. In Activity I need to getNews() from a URL, if news is not already cached. Activity will ask ViewModel to give the News Json and ViewModel will look in...

15

Solved

My understanding on LiveData is that, it will trigger observer on the current state change of data, and not a series of history state change of data. Currently, I have a MainFragment, which perform...

4

Solved

I am using LiveData, DataBinding, and Kotlin in my application. I defined a Binding Adapter for a RecyclerView like this: class MainListBindings { private val TAG = "TasksListBindings" compa...
Dougall asked 20/8, 2018 at 8:20

10

Solved

I have a separate class in which I handle data fetching (specifically Firebase) and I usually return LiveData objects from it and update them asynchronously. Now I want to have the returned data st...

7

Solved

In recent Android Architecture Components library released by Google, we have two static functions in the Transformations class. While the map function is straight forward and easily understandable...
Satisfied asked 2/12, 2017 at 17:42

4

Solved

I am trying to display several download progress bars at once via a list of data objects containing the download ID and the progress value. The values of this list of objects is being updated fine ...

5

Solved

I observed that MutableLiveData triggers onChanged of an observer even if the same object instance is provided to its setValue method. //Fragment#onCreateView - scenario1 val newValue = "newValue"...
Understudy asked 11/2, 2019 at 21:17

5

Solved

I have some questions about Kotlin Flow I can observe LiveData from multiple Fragments. Can I do this with Flow? If yes then how? We can have multiple LiveData from a single LiveData using map&amp...

3

Solved

After upgrading the lifecycle dependency from 2.6.0-alpha04 to 2.6.0-beta01 I got Unresolved reference: Transformations and it can't import androidx.lifecycle.Transformations class. import androidx...

4

Solved

Whenever you call .observe() on LiveData, the Observer receives the last value of that LiveData. This may be useful in some cases, but not in mine. Whenever I call .observe(), I want the Observe...

1

Solved

I just learned jetpack compose and I switched from recycle to lazy column but when I do it it lags much more than recycle after adding about 100 items to the application the app is lagging, is ther...

3

Let me start with example code snippets suspend fun executeLive(result: MutableLiveData<Person>) { val response = ... //suspend api request mediatorLiveData.removeSource(response) medi...
Sebi asked 21/1, 2020 at 8:19

2

With LiveData inside a Viewmodel we use switchMap or Transformations.map like this val recipesList = cuisineType.switchMap { repository.getDisplayRecipes(it.cuisineType).asLiveData() } What would ...
Wittenberg asked 7/2, 2021 at 20:59

9

Solved

I'm trying to trigger an update on LiveData from a coroutine: object AddressList: MutableLiveData<List<Address>>() fun getAddressesLiveData(): LiveData<List<Address>> { Ad...
Cogent asked 14/11, 2018 at 16:6

11

Solved

According to LiveData documentation: The LiveData class provides the following advantages: ... Always up to date data: If a Lifecycle starts again (like an activity going back to started state fro...
Dragging asked 16/6, 2017 at 6:14

7

Solved

Is there any way to enforce non-nullability of LiveData values? Default Observer implementation seems to have @Nullable annotation which forces an IDE to suggest that the value might be null and sh...

© 2022 - 2024 — McMap. All rights reserved.