jeudi 11 janvier 2018

Login Flow in Android Clean Architecture

I was looking to implement a simple Firebase Authentication Android Application using Clean Architecture, so as per Firebase Documentation the user can be checked if he's been logged in

@Override
public void onStart() {
    super.onStart();
    // Check if user is signed in (non-null) and update UI accordingly.
    FirebaseUser currentUser = mAuth.getCurrentUser();
    updateUI(currentUser);
}

so I am confused to as where should it put this condition, should it be in a UseCase or in the Presenter, called independently with help of same source object

something like

public interface FirebaseAuthDataSource {
    Single<User> loginUser(String username, String password);
    Single<User> isUserLoggedIn();
}
public class LoginUserUseCase {
  public Observable<ResponseValues> buildUseCase(RequestValues requestValues) {
   return firebaseAuthDataSource.loginUser(username,password);
  }
}
public class LoginPresenter{
 public void onStart(){
  firebaseAuthDataSource.isUserLoggedIn()
  .subscribe(LoginView::navigateToMenuScreen);
 }
}

so conditions like these, do they qualify as a Business logic ? or a Flow logic ?

Aucun commentaire:

Enregistrer un commentaire