UseCase problem?
Hi, I'm recently working on my android project code refactoring and I find your project.
I'm confused about using UseCase class which will be @Inject in Presentation Layer to get the data in Data Layer.
Will this be more convenient if we just @Inject the UserRepository in Presentation Layer directly, since UseCase(GetUserDetails) is just some kind of wrapping of UserRepository from my point of view.
Like this:
class UserDetailsPresenter{
private UserRepository userRepository;
...
@Inject
public UserDetailsPresenter(UserRepository userRepository){
...
}
...
//get the user detail
userRepository.user(this.userId).subscribeOn(...).observeOn(...).subscribe((data)->{});
....
}
For something that simple, yes it does appear to work. However as your data sets get more complicated, a UseCase can encompass combining multiple elements from the repository, and explicitly having this layer define what repository elements create a UseCase is supposed to help it scale as necessary.