class LoginInteractor {

    @NonNull
    public synchronized Observable<UiIndicator<String>> loginOrSignUp(@NonNull final UserCredentialsPayload userCredentialsPayload) {
        Logger.info(this, "Initiating user login (or sign up)");

        if (this.uiIndicatorReplaySubject == null) {
            this.userCredentialsPayload = userCredentialsPayload;
            this.uiIndicatorReplaySubject = ReplaySubject.create();

            identityManager.logInOrSignUp(userCredentialsPayload)
                    .map(loginResponse -> UiIndicator.success(getSuccessMessage(userCredentialsPayload)))
                    .onErrorReturn(throwable -> UiIndicator.error(getErrorMessage(userCredentialsPayload, throwable)))
                    .startWith(UiIndicator.loading())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(uiIndicatorReplaySubject);
        }
        return uiIndicatorReplaySubject;
    }

    @Inject public  LoginInteractor(@NonNull Context context, @NonNull IdentityManagerImpl identityManager);

}