在会议室数据库中,我有一个ID为“ 1”的对象(用户),我的DAO返回此对象的Flowable。订阅后,我调用editUser()函数。
@Query ("SELECT * FROM User Where id=:id ")
Flowable<User> getUser(String id);
@Update
void update(User user);
每当我对此用户对象进行更改并在数据库中对其进行更新时,都不会收到任何回调(onNext或onComplete)。
public void editUser() {
User u = new User();
u.id="1";
u.age=45;
appDB.userModel().update(u);
}
appDB.userModel().getUser("1").subscribe(new Subscriber<User>() {
@Override
public void onSubscribe(Subscription s) {
Log.d(TAG,"onSubscribed");
}
@Override
public void onNext(User user) {
Log.d(TAG,"onNext");
}
@Override
public void onError(Throwable t) {
Log.d(TAG,"Error");
}
@Override
public void onComplete() {
Log.d(TAG,"onComplete");
}
});
任何人都可以向我解释一下我在这里想念什么吗?
答案 0 :(得分:0)
来自Subscription
的请求!
appDB.userModel().getUser("1").subscribe(new Subscriber<User>() {
@Override
public void onSubscribe(Subscription s) {
Log.d(TAG,"onSubscribed");
// ------------------------------------------------------------------------
s.request(Long.MAX_VALUE);
// ------------------------------------------------------------------------
}
@Override
public void onNext(User user) {
Log.d(TAG,"onNext");
}
@Override
public void onError(Throwable t) {
Log.d(TAG,"Error");
}
@Override
public void onComplete() {
Log.d(TAG,"onComplete");
}
});