What is Call<> in retrofit?

Viewed 1107

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?

2 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>

Call is a method to request to the webserver/API to get data.(Based on my understanding)

Related