rx-android

Combination of RxJava and RxAndroid?

好久不见. 提交于 2019-12-08 07:42:49
问题 My Scenario is very similar to this Image: Flow of the app will be like this: View needs to get updated. Create an observable using RxAndroid to fetch the data from cache / local file. update the view. Make another network call using Retrofit and RxJava to update the view again with new data coming from the web services. Update the local file with the new data. So, I am updating the view twice(One from local file and just after that through webservices) How can I achieve the result using

How to continue streaming items after error in RxJava?

陌路散爱 提交于 2019-12-08 06:37:59
问题 I'm RxJava newbie, and I've got following problem. Say I have sequence of items and on of items propagates error, I want to ignore it and to continue processing other items. I have following snippet: Observable.from(Arrays.asList("1", "2", "3")) .map(x -> { if (x.equals("2")) { throw new NullPointerException(); } return x + "-"; }) .onExceptionResumeNext(Observable.empty()) .subscribe(System.out::println); I'm getting: 1- But I want to get: 1- , 3- How can I do that? 回答1: the trick is to wrap

Can we use Retrofit, RxJava, RxAndroid together?

元气小坏坏 提交于 2019-12-08 04:14:24
问题 I have used: compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'io.reactivex:rxandroid:1.2.1' compile 'com.squareup.retrofit2:retrofit compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' Should i use like this way, i read retrofit 1.x itself work on worker thread? Should i have to use rxJava and retrofit together or just retrofit work for me? 回答1: Yes you can. You should add this dependencies in your gradle: dependencies { ... compile 'com.squareup.retrofit2:retrofit:2.1.0' compile

Drop delete trigger for Room database

点点圈 提交于 2019-12-08 04:13:06
问题 I am using room database to store comments and RxJava as a listener to do some stuff when the database is changed. I want to not call the callback when delete is called on the table, only when insert is called. What i found out so far is that Room library has triggers that are called on delete , insert and update of the table that in turn call RxJava's methods. Is there any way to drop the delete trigger and get callbacks only for the insert and update methods? Here is my CommentDAO: @Query(

Asynchronous read / write to Realm using RXJava 2

喜欢而已 提交于 2019-12-08 04:05:29
问题 My first implementation of an asynchronous operation using RXJava 2 Goal: Get json data from the server with library Retrofit2 . If successful, then write the data to Realm and immediately after the record get the data back and send to the adapter of RecyclerView . So, I realized all this in this way: private void fetchChatsFromNetwork(int count, AccessDataModel accessDataModel) { String accessToken = accessDataModel.getAccessToken(); MyApplication.getRestApi().getChats(count, accessToken,

Can we use Retrofit, RxJava, RxAndroid together?

廉价感情. 提交于 2019-12-08 02:45:41
I have used: compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'io.reactivex:rxandroid:1.2.1' compile 'com.squareup.retrofit2:retrofit compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' Should i use like this way, i read retrofit 1.x itself work on worker thread? Should i have to use rxJava and retrofit together or just retrofit work for me? Yes you can. You should add this dependencies in your gradle: dependencies { ... compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' compile

RxAndroid Release Apk is not working for build 25.0.2

岁酱吖の 提交于 2019-12-07 17:22:14
问题 I have posted this on rxandroid issue page too but no response its been 4 days but no response , problem is in debug apk rxjava functionalities are working as expected , but in release apk , only functionalities related to rxjava or rxandroid are not working at all build.gradle(project) apply plugin: 'com.android.application' //or apply plugin: 'java' apply plugin: 'me.tatarka.retrolambda' apply plugin: 'com.jakewharton.hugo' apply plugin: 'android-apt' def AAVersion = '4.1.0' android {

RxJava: How to express doOnFirst()?

时光总嘲笑我的痴心妄想 提交于 2019-12-07 15:48:27
问题 I am using RxJava and I have an Observable with multiple items inside. What I would like to do is run function A on the first item, function B on all of them and function C when the Observable is completed: -----1-----2-----3-----|--> | | | | run A | | | | | | | run B run B run B | | run C is there a clever way of expressing this with lambda functions? I have the following solution already, but it looks ugly and I suspect that there is a better way to do this: observable.subscribe( new

What is the MutableLiveData equivalent in RxJava?

别来无恙 提交于 2019-12-07 05:09:31
问题 Per the example below from the LiveData Android documentation, what would be the RxJava 2 equivalent? We certainly can use a combination of publish() , refcount() and replay() to achieve the core of the MutableLiveData observable behavior. That said, what would be the analogous counterpart of mCurrentName.setValue() as it pertains to detecting a change and emitting the corresponding event? public class NameViewModel extends ViewModel { // Create a LiveData with a String private

Get JSON object one by one from JSON array in Android using Retrofit and RxJava

廉价感情. 提交于 2019-12-07 04:29:19
问题 I am using retrofit to hit my network api which returns json array. I am doing so using following code- Observable<MyJson[]> response = (Observable<MyJson[]>)mNetworkService.getReadyObserverable(mNetworkService.getNetworkServiceApi().getMyDataJsons(), MyJson.class, true, useCache); mAirlineSubscription = response.subscribe(new Observer<MyJson[]>() { @Override public void onCompleted() { Log.d(TAG, "getData completed.."); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " +