JakeWharton/u2020

Drop Observables from GalleryService

Closed this issue · 3 comments

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?

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 to GalleryDatabase) 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.

Good point, especially having to delegate the Retrofit exceptions will be a pain.

I've thought a lot about this as well.