Skip to content

[Flow] combineLatest with custom transformer (e.g. not map transformer) #1224

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

Closed
hrach opened this issue May 27, 2019 · 1 comment
Closed
Assignees
Labels

Comments

@hrach
Copy link
Contributor

hrach commented May 27, 2019

I miss combineLatest() which transformer behaves more like Flow.transform than Flow.map.

My usecase: I ('d like to) combine multiple flows and emit loading & success state between suspensions in trasformer:

val filter = ConflatedBroadcastChannel<Filter>()
val search = ConflatedBroadcastChannel<String>()

filter.asFlow().combineLatest(search.asFlow()) { f, s ->
    emit(LoadingResource())
   
    val data = fetchData(f, s) // suspending function
    emit(SuccessResource(data))
}

I may rewrite it to do a transformation to Pair, however it seems quite unnecessary and personally I have use cases for 4 flows (E.g. I would have to create a data class each time).

I could try to prepare a PR.

(Also, I would do this myself but the building-blocks of combineLatest are internal. :X)

@elizarov elizarov added the flow label May 29, 2019
@qwwdfsad qwwdfsad self-assigned this Jul 23, 2019
@qwwdfsad
Copy link
Collaborator

Thanks for the issue! Your report along with the provided example was very useful for designing current and upcoming operators.

qwwdfsad added a commit that referenced this issue Jul 25, 2019
  * Operator renamed to combine
  * Introduced combineTransform operator with custom transformer
  * Decouple API and implementation details to improve user experience from IDE
  * combine(Iterable<Flow>) and combineTransform(Iterable<Flow>) are introduced

Fixes #1224
Fixes #1262
qwwdfsad added a commit that referenced this issue Aug 6, 2019
  * Operator renamed to combine
  * Introduced combineTransform operator with custom transformer
  * Decouple API and implementation details to improve user experience from IDE
  * combine(Iterable<Flow>) and combineTransform(Iterable<Flow>) are introduced

Fixes #1224
Fixes #1262
qwwdfsad added a commit that referenced this issue Aug 9, 2019
  * Operator renamed to combine
  * Introduced combineTransform operator with custom transformer
  * Decouple API and implementation details to improve user experience from IDE
  * combine(Iterable<Flow>) and combineTransform(Iterable<Flow>) are introduced

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

No branches or pull requests

3 participants