Open mHerasimov opened 7 years ago
why no one answer ?. i am also interested in this
ok, let's summarize, I see 2 versions
use Interactor & Presenter & View pros
cons
perform call from presentation layer to domain layer directly pros
cons
currently I think of creation of interface like this for synchronos simple actions
interface SyncUseCase<T, R> {
R perform(T t);
}
it will remove direct calls from Activity/Fragment to Repositopy
currently I am not sure which way is right and it'll be good if someone correct me
@chanhoncongian I'll ask on SO, meaby somebody will answer here is question
Hi guys, eventually I came across this issue. I've read code of various repos related to Clean Architecture including this one. Author of this repo creates interactor for each repository method. But we can use one presenter for multiple interactors, as author does. Just take a look at interactors and presenters implementations. So we should design our presenters, keeping in mind views (Fragment/Activity) for which we are designing them.
As you can see there is size() method that returns number of records in database or in file, whatever. And this method is pretty fast.
I think we (developers) shouldn't think like this. We don't know how long each repository method would be executing. And there is the answer. Each repository method must be executed asynchronously. We can write UseCase for this or invoke repository method directly but without blocking main thread.
Does we need to create UseCases for each method from Repository interface in domain layer?
For example assume that I have such Repository interface
As you can see there is
size()
method that returns number of records in database or in file, whatever. And this method is pretty fast. I guess that there is no need for UseCase for this method because it wouldn't block UI thread and can be executed synchronously.So could you explain me when you create UseCases and when you don't. Basically is there any rules for UseCase creation?
Sorry if there is some misunderstanding in this issue.