我有:在道:
@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);
}
}
在viewmodel中:
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?
1条答案
按热度按时间9cbw7uwe1#
}