rx-android

Why onNext() is updating textview, though observeOn(Schedulars.io()) on a different thread?

℡╲_俬逩灬. 提交于 2021-02-11 04:31:19
问题 Observable.range(11,10).subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(new Observer<Integer>() { @Override public void onSubscribe(@NonNull Disposable d) { } @Override public void onNext(@NonNull Integer integer) { textView.setText(String.valueOf(integer)); Log.d(TAG, "onNext: "+Thread.currentThread().getName()); } @Override public void onError(@NonNull Throwable e) { } @Override public void onComplete() { } }); onNext() supposed to run on separate thread, but how is it

Insert into SQLiteDatabase using RxJava2 in Android

旧时模样 提交于 2021-02-08 06:09:06
问题 I am learning RxJava2 in android. Can Anyone explain me how can we insert Data into SQLiteDatabase using RxJava2 . Here a code sample i am trying to use, but it inserts the data Six Times into the Database; //OnClick getCompletableObservable() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(getCompletableObserver()); //Observable private Completable getCompletableObservable(){ return Completable.create(new CompletableOnSubscribe() { @Override public void

Insert into SQLiteDatabase using RxJava2 in Android

倾然丶 夕夏残阳落幕 提交于 2021-02-08 06:07:05
问题 I am learning RxJava2 in android. Can Anyone explain me how can we insert Data into SQLiteDatabase using RxJava2 . Here a code sample i am trying to use, but it inserts the data Six Times into the Database; //OnClick getCompletableObservable() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(getCompletableObserver()); //Observable private Completable getCompletableObservable(){ return Completable.create(new CompletableOnSubscribe() { @Override public void

Insert into SQLiteDatabase using RxJava2 in Android

别说谁变了你拦得住时间么 提交于 2021-02-08 06:05:33
问题 I am learning RxJava2 in android. Can Anyone explain me how can we insert Data into SQLiteDatabase using RxJava2 . Here a code sample i am trying to use, but it inserts the data Six Times into the Database; //OnClick getCompletableObservable() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(getCompletableObserver()); //Observable private Completable getCompletableObservable(){ return Completable.create(new CompletableOnSubscribe() { @Override public void

Insert into SQLiteDatabase using RxJava2 in Android

自作多情 提交于 2021-02-08 06:05:28
问题 I am learning RxJava2 in android. Can Anyone explain me how can we insert Data into SQLiteDatabase using RxJava2 . Here a code sample i am trying to use, but it inserts the data Six Times into the Database; //OnClick getCompletableObservable() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(getCompletableObserver()); //Observable private Completable getCompletableObservable(){ return Completable.create(new CompletableOnSubscribe() { @Override public void

How to handle multiple data sources with rxjava?

社会主义新天地 提交于 2021-02-08 03:46:53
问题 This is the case: I have the domain layer to provide data fetching interface for business logics, and I have 2 data sources: local database and remote network. It works like this: Request all users: DataRepository.getInstance().getUsers(); In DataRepository, there are 2 sources: LocalDataSource.getUsers() which fetches all users from local database, if there is no data then ignore this request. RemoteDataSource.getUsers() which requests latest user list from our server(Even if there is data

How to handle multiple data sources with rxjava?

蹲街弑〆低调 提交于 2021-02-08 03:46:25
问题 This is the case: I have the domain layer to provide data fetching interface for business logics, and I have 2 data sources: local database and remote network. It works like this: Request all users: DataRepository.getInstance().getUsers(); In DataRepository, there are 2 sources: LocalDataSource.getUsers() which fetches all users from local database, if there is no data then ignore this request. RemoteDataSource.getUsers() which requests latest user list from our server(Even if there is data

Rx - How to unsubscribe automatically after receiving onNext()?

旧巷老猫 提交于 2021-02-07 05:08:38
问题 How to unsubscribe automatically after receiving onNext() ? For now I use this code: rxObservable .compose(bindToLifecycle()) // unsubscribe automatically in onPause() if method was called in onResume() .subscribe(new Subscriber<Object>() { ... @Override public void onNext(Object o) { unsubscribe(); } }); 回答1: I you want to "unsubscribe" just after the first event, the operator take is a way to go. rxObservable.compose(bindToLifecycle()) .take(1) .subscribe(); 回答2: I think this is what you

Rx - How to unsubscribe automatically after receiving onNext()?

对着背影说爱祢 提交于 2021-02-07 05:05:12
问题 How to unsubscribe automatically after receiving onNext() ? For now I use this code: rxObservable .compose(bindToLifecycle()) // unsubscribe automatically in onPause() if method was called in onResume() .subscribe(new Subscriber<Object>() { ... @Override public void onNext(Object o) { unsubscribe(); } }); 回答1: I you want to "unsubscribe" just after the first event, the operator take is a way to go. rxObservable.compose(bindToLifecycle()) .take(1) .subscribe(); 回答2: I think this is what you

RxJava: Error occurred when trying to propagate error to Observer.onError

眉间皱痕 提交于 2021-02-06 14:20:38
问题 I am getting a IllegalStateException error in the Rx Library and don't know exactly where the root of the issue is, whether it is with RxJava or something I may be doing incorrectly. The fatal crash occurs when certificate pinning (occurs on all server requests) but seems to point to a session timeout or logout and back in. Repro steps (occures about 25% of the time) are as follows: login, open list item - scroll all the way end - logout - logback in - open app - close app -> Crash! Anyone