Drop Observables from GalleryService
Closed this issue · 3 comments
f2prateek commented
Have the GalleryService
class simply return the raw types, which are then wrapped into observables by the GalleryDatabase
.
@GET("/gallery/{section}/{sort}/{page}") //
Gallery listGallery( //
@Path("section") Section section, //
@Path("sort") Sort sort, //
@Path("page") int page);
Main advantage would be that the mock implementation of GalleryService
wouldn't have to worry about dealing with producing the observables.
Any thoughts?
JakeWharton commented
The downsides to this approach are:
- Caller has to deal with dictating worker thread. This probably means having a singleton
Scheduler
with a@Background
or@Worker
qualifier that gets injected around (currently only toGalleryDatabase
) for callers to use. - Caller has to try/catch Retrofit exceptions and delegate to the respective
Observable
methods itself.
As far as I can tell, the only upside is that mock implementations can simply return values rather than being forced to wrap.
f2prateek commented
Good point, especially having to delegate the Retrofit exceptions will be a pain.
JakeWharton commented
I've thought a lot about this as well.