Skip to content

Instantly share code, notes, and snippets.

View PatrickKuijpers's full-sized avatar

Patrick PatrickKuijpers

  • 9292
View GitHub Profile
@marcellogalhardo
marcellogalhardo / SavedStateHandle+StateFlow.kt
Last active July 23, 2023 23:46
A helper function to let you expose a MutableStateFlow from a SavedStateHandle.
/**
* Returns a [StateFlow] that access data associated with the given key.
*
* @param scope The scope used to synchronize the [StateFlow] and [SavedStateHandle]
* @param key The identifier for the value
* @param initialValue If no value exists with the given [key], a new one is created
* with the given [initialValue].
*
* @see SavedStateHandle.getLiveData
*/