遵循observeForever时不提供任何数据 -用户已注销(数据库中没有用户) -登录并将用户插入数据库。 (在这里未触发watchForever)
mUserDao.getCompleteUser().observeForever(this::updateCompleteUser);
DAO
@Dao
public interface UserDao extends BaseDao<User> {
@Query("SELECT * FROM user")
@Transaction
LiveData<CompleteUser> getCompleteUser();
}
但是@Query("SELECT * FROM user")
@Transaction
Flowable<CompleteUser> getCompleteUser();
正在工作,对于注销状态(预期行为)不会返回null
用户
@Entity(tableName = "user")
public class User implements Serializable {
@PrimaryKey
@NonNull
String uid;
String email;
}
完整用户
public class CompleteUser {
@Embedded
User user;
@Relation(parentColumn = "uid", entityColumn = "userId", entity = Address.class)
List<Address> addresses;
}