sockeqwe / sqlbrite-dao

DAO for SQLBrite
http://hannesdorfmann.com/android/sqlbrite-dao
Apache License 2.0
182 stars 22 forks source link

query mapper for single object using Observable<T> #35

Open ziahaqi opened 8 years ago

ziahaqi commented 8 years ago

i try to get single user data using Observer getUser(int id) method. but the subscriber dont get back enything, what wrong ? I've been using a query like this : return query(SELECT(USER_PROJECTION) .FROM(User.TABLE_NAME) .WHERE(User.COL_ID + " = ?")) .args(String.valueOf(userId)) .run() .mapToOne(new Func1<Cursor, User>() { @Override public User call(Cursor cursor) { //.... } }) I have tried mapToOne(UserMapper.MAPPER). and the result still same.

sockeqwe commented 8 years ago

Do you subscribed to that observable? Is Subscriber.onNext() or Subscriber.onError() really never called?

ziahaqi commented 8 years ago

yes i did. I already subscribe method on my Presenter by this way :

userObservable.observeOn(AndroidSchedulers.mainThread()). subscribe(new Subscriber() { @Override public void onCompleted() { Log.i(TAG, "onCompleted"); }

                        @Override
                        public void onError(Throwable e) {
                            mLoginView.showError(e.getMessage());
                        }

                        @Override
                        public void onNext(User user) {
                            mLoginView.onGetUserSuccess(user); 
                        }
                    });
sockeqwe commented 8 years ago

Can you provide me with some code that I can run and debug?

I really would be surprised if there is a bug in SQLBrite or SQLBrite-DAO