// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/domain/Person.java
// public class Person {
// 
//     private String name;
// 
//     public Person(String name) {
//         this.name = name;
//     }
// 
//     public String getName() {
//         return name;
//     }
// }
// 
// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/domain/usecase/GetAllPersonsUseCase.java
// public class GetAllPersonsUseCase extends UseCase<List<Person>>{
//     private final PersonRepositoryImp repository;
// 
//     private final Scheduler uiThread;
//     private final Scheduler executorThread;
// 
//     @Inject
//     public GetAllPersonsUseCase(PersonRepositoryImp repository, @Named("mainThread") Scheduler uiThread, @Named("executorThread") Scheduler executorThread) {
//         this.repository = repository;
//         this.uiThread = uiThread;
//         this.executorThread = executorThread;
//     }
// 
//     @Override
//     protected Observable<List<Person>> buildUseCaseObservable() {
//         return repository.getAll()
//                 .observeOn(uiThread)
//                 .subscribeOn(executorThread);
//     }
// }


import com.tonilopezmr.dagger2rxjava.domain.Person;
import com.tonilopezmr.dagger2rxjava.domain.usecase.GetAllPersonsUseCase;
import java.util.List;
import javax.inject.Inject;
import rx.Subscription;
package com.tonilopezmr.dagger2rxjava.presenter;





/**
 * @author Antonio López.
 */
public class PersonListPresenter implements Presenter<PersonListPresenter.View> {

    private final GetAllPersonsUseCase personsUseCase;
    private  PersonListPresenter.View view;

    private Subscription personsSubscription;

    @Inject
    public PersonListPresenter(GetAllPersonsUseCase personsUseCase) {
        this.personsUseCase = personsUseCase;
    }

    @Override
    public void init() {
        askForPersons();
    }

    private void askForPersons() {
        personsSubscription = personsUseCase.execute()
                .subscribe(this::onPersonReceived, this::showError);
    }

// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/domain/Person.java
// public class Person {
// 
//     private String name;
// 
//     public Person(String name) {
//         this.name = name;
//     }
// 
//     public String getName() {
//         return name;
//     }
// }
// 
// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/domain/usecase/GetAllPersonsUseCase.java
// public class GetAllPersonsUseCase extends UseCase<List<Person>>{
//     private final PersonRepositoryImp repository;
// 
//     private final Scheduler uiThread;
//     private final Scheduler executorThread;
// 
//     @Inject
//     public GetAllPersonsUseCase(PersonRepositoryImp repository, @Named("mainThread") Scheduler uiThread, @Named("executorThread") Scheduler executorThread) {
//         this.repository = repository;
//         this.uiThread = uiThread;
//         this.executorThread = executorThread;
//     }
// 
//     @Override
//     protected Observable<List<Person>> buildUseCaseObservable() {
//         return repository.getAll()
//                 .observeOn(uiThread)
//                 .subscribeOn(executorThread);
//     }
// }


// Path: dagger2-rxjava/src/main/java/com/tonilopezmr/dagger2rxjava/presenter/PersonListPresenter.java
import com.tonilopezmr.dagger2rxjava.domain.Person;
import com.tonilopezmr.dagger2rxjava.domain.usecase.GetAllPersonsUseCase;
import java.util.List;
import javax.inject.Inject;
import rx.Subscription;

package com.tonilopezmr.dagger2rxjava.presenter;





/**
 * @author Antonio López.
 */
public class PersonListPresenter implements Presenter<PersonListPresenter.View> {

    private final GetAllPersonsUseCase personsUseCase;
    private  PersonListPresenter.View view;

    private Subscription personsSubscription;

    @Inject
    public PersonListPresenter(GetAllPersonsUseCase personsUseCase) {
        this.personsUseCase = personsUseCase;
    }

    @Override
    public void init() {
        askForPersons();
    }

    private void askForPersons() {
        personsSubscription = personsUseCase.execute()
                .subscribe(this::onPersonReceived, this::showError);
    }

    private void onPersonReceived(List<Person> persons) {