rx-java2

RXJava. Identify when all obervables inside for loop are finished

房东的猫 提交于 2021-02-08 07:41:07
问题 I want to perform the following. I have a list of transactions which i want to update by making 2 api requests (i am using retrofit2), for each transactions and then saving the result into a database(using the observer). After some searching i decided to use zip operator to combine the 2 requests but the issue that i'm have is that i cannot identify when the whole process is finished to update the UI. Code looks like this. for (Transaction realmTransaction : allTransactions) { Observable<Map

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

Use flatMap or zip in RxJava2?

本秂侑毒 提交于 2021-02-07 08:40:25
问题 I have a class called Student and it has two fields grade and school . Both of two fields need to be fetched from remote server. When two result returned, I new a Student object. With help of RxJava , I have done it in two ways, one in flatMap and another in zip operator. Observable<String> gradeObservable = Observable.create((ObservableOnSubscribe<String>) emitter -> { Thread.sleep(1000); emitter.onNext("senior"); }).subscribeOn(Schedulers.io()); Observable<String> schoolObservable =

Use flatMap or zip in RxJava2?

五迷三道 提交于 2021-02-07 08:39:46
问题 I have a class called Student and it has two fields grade and school . Both of two fields need to be fetched from remote server. When two result returned, I new a Student object. With help of RxJava , I have done it in two ways, one in flatMap and another in zip operator. Observable<String> gradeObservable = Observable.create((ObservableOnSubscribe<String>) emitter -> { Thread.sleep(1000); emitter.onNext("senior"); }).subscribeOn(Schedulers.io()); Observable<String> schoolObservable =

RxJava2 toList() never emits

心已入冬 提交于 2021-02-07 07:53:41
问题 So I have following Disposable which doesn't work. I am using Room to get all rows from a table as a list, map each of them to something and create a list and then it doesn't continue from there. storedSuggestionDao .getSuggestionsOrderByType() //Flowable .doOnNext(storedSuggestions -> Timber.e("storedSuggestions: " + storedSuggestions)) //this work .flatMapIterable(storedSuggestions -> storedSuggestions) .map(Selection::create) )) .doOnNext(selection -> Timber.e("Selection: " + selection)) /

lateinit property data has not been initialized

老子叫甜甜 提交于 2021-02-05 05:57:26
问题 Gson Convertable data is not set in Recyclerview using Retrofit2 and rxjava2 then subscribe throughble its Give Error: UninitializedPropertyAccessException: lateinit property data has not been initialized JSON data parsing by retrofit2 and rxjava2. when parsing GSON Data Converting GSon, rxjava2 Subscribe the data then give lateinit property error and its not set in recyclerview. MainActivity.kt class Company : AppCompatActivity() { internal lateinit var api : APIInterface var

How to call multiple Flowable statements in parallel?

我只是一个虾纸丫 提交于 2021-01-29 18:12:55
问题 I have a few function calls that return Flowable object. I have to call this function multiple times and this function is doing some network calls. I want to do all these calls concurrently. Below is the code. Interface containing the function public Interface XYZDownstreamService { Flowable<String> getData(Request request); } Below is the Caller public List<String> getDataFromDownstreamForRequests(List<Request> requests, XYZDownstreamService service) { List<String> dataFromDownstream = Lists