Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Call<> in retrofit?

I am learning retrofit and cannot understand what is Call<> in that means.

Even the docs are too hard to understand.

Can someone give a clear explanation on this?

like image 329
ADITYA DIXIT Avatar asked Nov 15 '25 16:11

ADITYA DIXIT


1 Answers

Think of Call as a simple class which wraps your API response and you need this class make an API call and provide listeners/callback to notify you with error and response , although if you use kotlin coroutines then after version 2.6.0 or retrofit you can totally abandon Call , you can directly return response from the function and you don't need any callback which is very clean.

do if like

@GET("users/{id}")
suspend fun user(@Path("id") id: Long): User

or

@GET("users/{id}")
suspend fun user(@Path("id") id: Long): Response<User>
like image 190
Abhinav Chauhan Avatar answered Nov 18 '25 06:11

Abhinav Chauhan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!