Skip to content

Data fetched from local DB doesn't show while remote request are running. #3

@isabsent

Description

@isabsent

Hi! Thanks for the code sharing!
I have found you are not showing data fetched from local DB while the remote request is running:

    moviesListViewModel.getMoviesLiveData().observe(this, resource -> {
        if(resource.isLoading()) {
            //updateMoviesList(resource.data); - SHOULD BE HERE!
        } else if(!resource.data.isEmpty()) {
            updateMoviesList(resource.data);

        } else handleErrorResponse();
    });

What is the reason for such approach?

P.S.: Another point is you should not check resource.data.isEmpty() before updateMoviesList because of all movies can be removed from a remote server, but you will still have them on a local device screen

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