Skip to content

Instantly share code, notes, and snippets.

@iammert
Created July 11, 2017 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iammert/d126c82559ec921c56474011951d4739 to your computer and use it in GitHub Desktop.
Save iammert/d126c82559ec921c56474011951d4739 to your computer and use it in GitHub Desktop.
RadioRepository.java
public class RadioRepository {
//...
public Flowable<Resource<List<GenreEntity>>> getGenres() {
return Flowable.create(emitter -> new NetworkBoundSource<List<GenreEntity>, List<Genre>>(emitter) {
@Override
public Single<List<Genre>> getRemote() {
return firebaseService.getGenres();
}
@Override
public Flowable<List<GenreEntity>> getLocal() {
return genresDao.getAll();
}
@Override
public void saveCallResult(List<GenreEntity> data) {
genresDao.insert(data);
}
@Override
public Function<List<Genre>, List<GenreEntity>> mapper() {
return EntityMapper.convert();
}
}, BackpressureStrategy.BUFFER);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment