Android-CleanArchitecture
Android-CleanArchitecture copied to clipboard
UseCases that fetch data as Single or Completable?
In this project, all UseCases
are treated (observed) like they fetch data as Observable<T>
, as we need to implement the buildUseCaseObservable
abstract method. But, quite frequently, it is more appropriate to retrieve data as Single<T>
or even use Completable
to know if some task completed or not.
What is the recommended way, if I want to use Single<T>
or Completable
instead of Observable<T>
?
Sorry for my bad english.
I think you can create another abstract class for UseCase that return an instance of Single
and Completable
. The code is just the save as the Observable<T>
one but the return of buildUseCaseObservable
will change to Single
and Completable
. You know what task need to retrieve data or completable so you can extend from the appropriate base class.