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

combineAndCollect: combine and collect flows #199

Open
hoc081098 opened this issue Nov 12, 2023 · 0 comments
Open

combineAndCollect: combine and collect flows #199

hoc081098 opened this issue Nov 12, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed PRs-are-welcome

Comments

@hoc081098
Copy link
Owner

public suspend fun <T1, T2> combineAndCollect(
  flow1: Flow<T1>,
  flow2: Flow<T2>,
  collector: suspend (a: T1, b: T2) -> Unit,
)

Example

class MyActivity : AppCompatActivity() {
  fun onCreate(...) {
    lifecycleScope.launch {
      repeatOnLifecycle {
        combineAndCollect(viewModel.uiStateFlow, xxxStateFlow) { uiState, xxx -> renderUi(uiState, xxx) }
      }
    }
  }
}
@hoc081098 hoc081098 added documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers PRs-are-welcome labels Nov 12, 2023
@hoc081098 hoc081098 changed the title combineAndCollect: combine and collect flows combineAndCollect: combine and collect flows Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed PRs-are-welcome
Projects
None yet
Development

No branches or pull requests

1 participant