Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created June 23, 2022 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatilShreyas/67c29058de6d016bf26f62f1d2eec552 to your computer and use it in GitHub Desktop.
Save PatilShreyas/67c29058de6d016bf26f62f1d2eec552 to your computer and use it in GitHub Desktop.
/**
* Variant of [combineStates] for combining 3 state flows
*/
inline fun <reified T1, reified T2, reified T3, R> combineStates(
flow1: StateFlow<T1>,
flow2: StateFlow<T2>,
flow3: StateFlow<T3>,
crossinline transform: (T1, T2, T3) -> R
) = combineStates(flow1, flow2, flow3) { (t1, t2, t3) ->
transform(
t1 as T1,
t2 as T2,
t3 as T3
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment