Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Owner and Founder. Opencart
Top Partners
In this blog we are going handle api calls using Rxjava and Retrofit library which makes simple and cleaner way to define API.
RxJava is a Java VM implementation of Reactive Extensions a library for composing asynchronous and event-based programs by using observable sequences.
Retrofit is a REST Client for Android and Java. It makes it relatively easy to retrieve and upload JSON. Retrofit uses the OkHttp library for HTTP requests.
Add the following dependencies to your gradle file
Once the dependencies are all set up, We would need an instance of Retrofit to make network calls.
baseUrl-> Set up Base URL of API
addConverterFactory() — converter factory for serialization and deserialization of objects
We can define post parameter for the API. The APIs are declared in an interface:
In Rx, the subscriber implements three methods to interact with observable:
For Android, to subscribe to an observable, we first tell the observable about the threads on which we plan to subscribe to and observe.
Making an API call:
That’s it, we can use the Observable/Flowable returned by the API and subscribe() to it to handle the data
Merging the multiple requests in Rxandroid
Merge operator combine multiple observable into one
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Osama
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.