I'm new in Kotlin Flow. I'd like use with Retrofit...
# android
a
I'm new in Kotlin Flow. I'd like use with Retrofit but i don't understand if and when can i use Flow in Retrofit interface. I 'm using slack eithernet to get network response :
Copy code
@GET("v2//news")
suspend fun news() : ApiResult<List<News>, ErrorResponse>
In this way i can't use
Flow<ApiResult<List<News>, ErrorResponse>>
so can i use in repo?
fun getNews(): Flow<List<News>> {
return flow {
}
}
i
Which error message when you tried to get with Flow?
a
nothing, i 'd like understand when use Flow with Retrofit
z
Flow is for streams, but retrofit just gives you a single response, so you define suspend functions instead. Suspend functions and flows interop in a number of ways, but there’s nothing specific to retrofit there.
7
a
Thanks
p
Only specific might be that you can't use Unit as a result when you don't have a response body
So you need to workaround with a Response<Void?> iirc