I'm wondering if adopting a clean architecture approach particularly with regards to thread scheduling and callbacks goes against the functional event driven approach of RxJava or if it makes sense to try and combine them. Is there a best practice for functional reactive programming in the clean architecture?
You can take a look at this repo: https://github.com/android10/Android-CleanArchitecture
Take a look at this repo
It's a finished example of the TODO repo with Clean architecture & RxJava.
Is it finished?
I麓ve ported MVP + Clean Architecture to RxJava as well.
Callbacks were removed and use cases just receive a RequestValues and the response is an Observable.
GetTask.RequestValues requestValues = new GetTask.RequestValues(mTaskId);
getTask.execute(requestValues,new Subscriber<Task>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
// The view may not be able to handle UI updates anymore
if (!mTaskDetailView.isActive()) {
return;
}
mTaskDetailView.showMissingTask();
}
@Override
public void onNext(Task task) {
// The view may not be able to handle UI updates anymore
if (!mTaskDetailView.isActive()) {
return;
}
mTaskDetailView.setLoadingIndicator(false);
showTask(task);
}
});
The TaskRepository is synchronous and Use Cases are asynchronous
Take a look at my repo MVP+Clean+RxJava
that is awesome @davidbaena, I'm looking at it and will give you proper feedback once I've checked out the branch. At a first glance it looks pretty good, thanks for sharing!
@davidbaena looks good but the README is very important and it's not updated. Can you reset it and write about design and key decisions? Thanks!
@davidbaena There are two Injection classes one for prod and other for mock, one is used depending upon the variant in use. It seems you have only made changes to mock and not to prod which is resulting in compile time error. Try selecting prodDebug or prodRelease in build variants to reproduce the error.
Most helpful comment
I麓ve ported MVP + Clean Architecture to RxJava as well.
Callbacks were removed and use cases just receive a RequestValues and the response is an Observable.
The TaskRepository is synchronous and Use Cases are asynchronous
Take a look at my repo MVP+Clean+RxJava