Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support adapter for Kotlin Coroutine Flow #3497

Closed
PatilShreyas opened this issue Nov 19, 2020 · 2 comments
Closed

[Feature Request] Support adapter for Kotlin Coroutine Flow #3497

PatilShreyas opened this issue Nov 19, 2020 · 2 comments

Comments

@PatilShreyas
Copy link

Feature Request

It would be great if it supports Kotlin Coroutine Flow<T> adapter for getting a response in the stream.

For example:

interface FeedApi {
    @GET("/")
    fun getPosts(): Flow<List<Post>>
}

If this is available then it will be easy to use and it'll be easy to map network response to the app's data model and for many Flow specific operations as well.

@JakeWharton
Copy link
Member

HTTP requests return a single response, not a stream of responses, and so only suspend fun is supported.

interface FeedApi {
    @GET("/")
    suspend fun getPosts(): List<Post>
}

If you need to emit this as a flow you can do something like

flow {
  emit(getPosts())
}

We won't be supporting Flow out of the box, and if we had the chance to do the RxJava adapters over again we probably wouldn't support their Observable either (Single is the natural type to use).

@PatilShreyas
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants