Posts

Showing posts with the label rx-java2

returning subscriber in RxJava after storing data fetch from webservice

returning subscriber in RxJava after storing data fetch from webservice I am trying to call the web service to fetch the data and storing it into database using following code. I have created a separate class to perform following operation. Now , the issue is i want to notify my activity when i successfully fetch and store data in database. if some error occurs then i want to show that on UI itself. somehow i am able to write a code to fetch the data using pagination but not sure how would i notify UI where i can subscribe catch the update related to progress and error if any. public Flowable<Response> getFitnessData() { Request request = new Request(); request.setAccess_token("d80fa6bd6f78cc704104d61146c599bc94b82ca225349ee68762fc6c70d2dcf0"); Flowable<Response> fitnessFlowable = new WebRequest() .getRemoteClient() .create(FitnessApi.class) ...

multiple api request using retrofit and rx java

multiple api request using retrofit and rx java I am new to android and I have a scenario where I want to get get data from multiple api. Let suppose api_a , api_b , api_c , api_d . These api are independent of each other but I want to show data from these api in a mix Recycler View ( horizontal and vertical ). So I want to make these api call in such a manner so that I can get every api data at a time so that i can display in recycler view. I already using retrofit 2 but for that I had to chain them one by one which is very lengthy and I think this is not a feasible approach. I know little bit about RX JAVA ,but I only know how to make one request at a time. Please help Try the accepted answer - stackoverflow.com/questions/36401193/… – Sanchita Santra Jun 30 at 10:39 suppose the result ...

How to use retryWhen only 3 times then give up

How to use retryWhen only 3 times then give up I want to filter when specific exception occurs during execution of some of the upper chain function and try to retry the whole process only 3 times then if it still failes then give up. I came to something like this: val disposable = someFunction(someParameter, delay, subject) .flatMapCompletable { (parameter1, parameter2) -> anotherFunction(parameter1, parameter2, subject) } .retryWhen { throwable -> throwable.filter { it.cause?.cause is ExampleException1 || it.cause?.cause is ExampleException2 || it.cause is ExampleException3 } } .andThen(someStuff()) .subscribe({ Timber.d("Finished!") }, { Timber.d("Failed!") }) How to do it properly? 2 Answers 2 You may use zipWith with a range to achieve this. zipWith range .retryWhen { erro...