ARR.s
ARR.s

Reputation: 769

How to use retrofit2 + rxjava2 mvp android

How to use retrofit2 + rxjava2 in android

I want to learn about sent parameter to server and get data from server with retrofit2 + rxjava2

Can you get some example for me? thanks!

Upvotes: 1

Views: 655

Answers (2)

Kostadin Georgiev
Kostadin Georgiev

Reputation: 895

There are a lot of guides over the network describing MVP pattern,Reactive-programing and Retrofit.

First you should understand what is the idea of the MVP pattern stands for(Model-View-Presenter).

Shortly the idea will be: in most cases your view needs some data from the beck-end and when it's received to be populated for the user. Using MVP pattern you will have something like this:

View needs some data and for that is invoking the presenter then presenter is invoking the model

enter image description here

The model in your case can represents a Repository with a Service(Retrofit) or DAO The return result should be some observable(RxJava2) And with a few words you will have something like this:

**Getting some data from server:** View -> Presenter -> Repository -> Service **Receiving the data from server:** Response -> Presenter -> View

Note that this is a very high-level of explanation, my advise will be to read carefully about the MVP,RxJava2 and Retrofit separately and when you feel you are ready to try combine it withing one project.

You can find some info about RxJava2 + Retrofit2 here:https://android.jlelse.eu/implementing-rxjava2-retrofit2-for-better-performance-during-api-calls-fe1c53e1f939

Upvotes: 0

DDH
DDH

Reputation: 29

Please check this blog. It could take some time to understand about mvi and immutable states, but it is based on rxjava2, has retrofit examples and overall architecture of application http://hannesdorfmann.com/android/model-view-intent

But mvp quite well explained here: http://hannesdorfmann.com/mosby/first-app/ Using mosby as library

Upvotes: 1

Related Questions