I'm developing an Android app using Clean Architecture and I'm migrating it to RxJava 2.x. I have to make some network requests to a soap service, so I defined the api interface in the domain module:
public interface SiginterApi {
Observable<User> login(String user, String password);
...
Observable<List<Campaign>> getCampaigns(List<Long> campaignIds);
}
I've read that a network request should be made with "Flowable
", because of the backpressure management since it's a 'cold observable'. On the other hand, I know the result of the request will be success (with the response) or error, so I don't know if I should use Flowable
or Single
or even Observable
.
Furthermore, I have a database accesses like this:
public interface UserRepository extends Repository {
Observable<Void> saveUser(String username, String hashedPassword, boolean logged, User user);
...
Observable<User> findUser(String username, String hashedPassword);
}
I don't know if I should use Completable
/Flowable
/Observable
in saveUser
method and Single
/Flowable
/Observable
in findUser
method.
Single
would be the better option to network requests, because of the single response, but as you can read in this question and many other blogs about RxJava 2.x, network and database accessors should be made withFlowable
. – Goethe