Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created June 23, 2022 13:17
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/13ee3d301e15d7dbe6eca4831b43572e to your computer and use it in GitHub Desktop.
Save PatilShreyas/13ee3d301e15d7dbe6eca4831b43572e to your computer and use it in GitHub Desktop.
class Preferences {
fun getPreferenceState(key: String): StateFlow<PreferenceState> { ... }
fun getMultiplePreferenceState(keys: List<String>): StateFlow<MultiplePreferenceState> {
val prefStateFlows = keys.map { getPreferenceState(it) }.toTypedArray()
return combineStates(*prefStateFlows) { prefStates: Array<PreferenceState> ->
MultiplePreferenceState(prefStates.toList())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment