Skip to content

Add combineLatest with multiple flows #1198

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

Merged
merged 1 commit into from
May 24, 2019
Merged

Add combineLatest with multiple flows #1198

merged 1 commit into from
May 24, 2019

Conversation

qwwdfsad
Copy link
Collaborator

  • combineLatest(Iterable<Flow>) is not added deliberately, use-case is unclear
  • All specific overloads are marked as inline to reduce binary compatibility pressure

Fixes #1193

  * combineLatest(Iterable<Flow<T>>) is not added deliberately, use-case is unclear
  * All specific overloads are marked as inline to reduce binary compatibility pressure

Fixes #1193
@qwwdfsad qwwdfsad requested a review from elizarov May 16, 2019 13:19
@qwwdfsad qwwdfsad changed the title Add combineLatest with multiple flow parameters Add combineLatest with multiple flows May 16, 2019
Copy link
Contributor

@elizarov elizarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good.

@qwwdfsad qwwdfsad merged commit 5627834 into develop May 24, 2019
@qwwdfsad qwwdfsad deleted the combine-latest branch May 24, 2019 08:22
@Thomas-Vos
Copy link
Contributor

Thomas-Vos commented Jun 7, 2019

combineLatest(Iterable) is not added deliberately, use-case is unclear

Here is my use case for this operator:

fun <T> combineLatest(flows: Iterable<Flow<T>>): Flow<List<T>> = TODO()

// A list of connected devices.
val devices: List<Device> = getDevices()

// A list of Flows which receive the state of the device every time it changes.
val flows: List<Flow<DeviceState>> = devices.map { device ->
    device.observeState() // Flow<DeviceState>
}

// Combine the latest state of the devices into a single Flow.
val flow: Flow<List<DeviceState>> = combineLatest(flows)


// Somewhere else in the code
flow.collect { states ->
    for (state in states) {
        // TODO: do something with the states.
    }
}

@elizarov
Copy link
Contributor

elizarov commented Jun 7, 2019

Please, create a separate issue.

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

Successfully merging this pull request may close these issues.

3 participants