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
itnoles
04/26/2021, 3:22 AM
Which error message when you tried to get with Flow?
a
Android75
04/26/2021, 3:57 AM
nothing, i 'd like understand when use Flow with Retrofit
z
Zach Klippenstein (he/him) [MOD]
04/26/2021, 4:17 AM
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
Android75
04/26/2021, 4:37 AM
Thanks
p
Paul Woitaschek
04/26/2021, 4:47 PM
Only specific might be that you can't use Unit as a result when you don't have a response body
Paul Woitaschek
04/26/2021, 4:47 PM
So you need to workaround with a Response<Void?> iirc