Kotlinx.coroutines: Provide combineLatest overload with vararg flow parameter

Created on 14 May 2019  路  2Comments  路  Source: Kotlin/kotlinx.coroutines

See the original request with rationale: https://github.com/Kotlin/kotlinx.coroutines/issues/437#issuecomment-491237681

The key question is how (if) to provide a type-safe API.
Whether we need up to N overloads with N generic parameters or single vararg parameter of type Flow<*>

flow

Most helpful comment

Once you start combining more than two Flows, does it make more sense to have combineLatest() as a standalone function rather than an extension method?

All 2 comments

I'd suggest to provide type-safe overloads up to N (5-8 TBD) parameters all based on internal implementation that uses varargs and is not typesafe to save bytecode size. There is no better solution as it seems until Kotlin implements "variadic generics" (https://youtrack.jetbrains.com/issue/KT-31427)

Once you start combining more than two Flows, does it make more sense to have combineLatest() as a standalone function rather than an extension method?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elizarov picture elizarov  路  3Comments

jaozinfs picture jaozinfs  路  3Comments

Leftwitch picture Leftwitch  路  3Comments

Pitel picture Pitel  路  3Comments

mariusstaicu picture mariusstaicu  路  3Comments