Skip to content

Instantly share code, notes, and snippets.

Last active September 8, 2023 17:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save krzdabrowski/9f98de2a999920cf8a6478735ac398dc to your computer and use it in GitHub Desktop.
private val intentsFlowListenerStarted = CompletableDeferred<Unit>()
private val changesPartialStateFlowListenerStarted = CompletableDeferred<Unit>()
private val intentsFlow = MutableSharedFlow<INTENT>()
private val changesPartialStateFlow = MutableSharedFlow<PARTIAL_UI_STATE>()
init {
viewModelScope.launch {
.scan(uiState.value, ::reduceUiState)
.catch { Timber.e(it) }
.collect {
savedStateHandle[SAVED_UI_STATE_KEY] = it
private fun userIntents(): Flow<PARTIAL_UI_STATE> =
.onSubscription { intentsFlowListenerStarted.complete(Unit) }
transform = ::mapIntents,
private fun nonUserChanges(): Flow<PARTIAL_UI_STATE> =
.onSubscription { changesPartialStateFlowListenerStarted.complete(Unit) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment