RxJava - 我必须在 ViewModel 的哪个位置为该方法编写线程?

RxJava - where in ViewModel I have to write threads for the method?

我有: 在道中:

    @Query("SELECT * FROM person_table WHERE status = :status_mudak ORDER BY RANDOM() LIMIT 5")
    Single<List<Person>> getFivePersonsFrom(String status_mudak);

回购中:

public class PersonRepository {
    public Single<List<Person>> getFivePersonsFrom(String status_mudak) {
        return mPersonDao.getFivePersonsFrom(status_mudak);
    }
}

在视图模型中:

public class PersonViewModel extends AndroidViewModel {
    private PersonRepository mRepository;
    //declaring variables
    public PersonViewModel(@NonNull Application application) {
        super(application);
        mRepository = new PersonRepository(application);
        //initializing variables
    }
    //methods
}

我必须在 ViewModel 的哪个位置分配线程,以将方法进一步移交给 LiveData?

public class PersonViewModel extends AndroidViewModel {
private PersonRepository mRepository;
private MutableLiveData<List<Person>> mPersonList = MutableLiveData<List<Person>>();
//declaring variables
public PersonViewModel(@NonNull Application application) {
    super(application);
    mRepository = new PersonRepository(application);
    //initializing variables
}

LiveData<List<Person>> getPersonList() {
    return mPersonList;
}

private void extractPersonList() {
    mRepository.getFivePersonsFrom("some_mudatskiy_status")
        .observeOn(/*rxSchedulers.main*/)
        .subscribe(this::updatePersonList);
}

private void updatePersonList(List<Person> personList) {
    mPersonList.postValue(personList);
}
//methods

}