Skip to content

Question about using MediatorLiveData #5

Description

@Deep21

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions