Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about using MediatorLiveData #5

Open
Deep21 opened this issue Dec 29, 2017 · 1 comment
Open

Question about using MediatorLiveData #5

Deep21 opened this issue Dec 29, 2017 · 1 comment

Comments

@Deep21
Copy link

Deep21 commented Dec 29, 2017

Hi,
This is not an issue but a question. There is no other way to ask a question.

Why you did not use an MediatorLiveData instead of observing 3 differents LiveData like you do:
viewModel.isLoadingLiveData.observe(this, Observer<Boolean> { it?.let { vRefresh.isRefreshing = it } })
viewModel.reposLiveData.observe(this, Observer<List<Repo>> { it?.let { adapter.dataSource = it } })
viewModel.throwableLiveData.observe(this, Observer<Throwable> { it?.let { Snackbar.make(rv, it.localizedMessage, Snackbar.LENGTH_LONG).show() } }).

You could add those 3 different source inside the mediatorLiveData and thus observing one livedata in the your activity/fragment.

@KucherenkoIhor
Copy link
Owner

Hi @Deep21 , maybe you are right, but in my case, I have 3 different data types inside livedatas. If I had wanted to merge ones I would have had some extra object to hold data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants