RxJava support
Any plans for adding support for RxJava by making service methods return observables?
No need since Retrofit2 already supports RxJava. Indeed, it supports every interface through call adapters
Add this library:
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
And extend the Tmdb class to add the support.
class RxTmdb extends Tmdb {
protected Retrofit.Builder retrofitBuilder() {
return super.retrofitBuilder().
.addCallAdapterFactory(RxJava2CallAdapterFactory.create());
}
}
@urizev But you still would have to change all the service method return types, no? Like:
@GET("search/movie")
Call<MovieResultsPage> movie(...);
has to be changed to:
@GET("search/movie")
Observable<MovieResultsPage> movie(...);
@NathHorrigan In any case, you should create a fork of this library and make the necessary adjustments (find/replace return types, add call adapter). Adding any possible RxJava method seems not useful.
Having separate RxMoviesService, etc, classes and an optional dependency on RxJava would probably not cause any issues for existing users tho
@UweTrottmann Yes, you're right. I didn't realize. 😞
I'll create a fork and let you know how it goes :)
I derived my local RxJava1 tmdb service and just using the entities. I guess we need 1 main (entities + Call) and 2 additional optional artifacts - RxJava and RxJava2. Don't know this packaging stuff well but you could check out how it is done in RxBinding for example.
I've pushed a fork with support for Kotlin and RxJava2. But it's built as an Android Gradle library not a pure Java artifact. https://github.com/sevar83/tmdb-rxjava2-kotlin
I created a fork, and relative pull request, in wich i duplcated all the services that return Observables. All the new Services can be found into the class Tmdb.rx
https://github.com/serafo27/tmdb-rxjava