Created
January 7, 2022 12:57
-
-
Save tunjid/887bfe7deb11d9824640c8fe04ac0a72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun archiveMutator( | |
scope: CoroutineScope, | |
route: ArchiveRoute, | |
repo: ArchiveRepository, | |
appMutator: AppMutator, | |
): Mutator<Action, StateFlow<State>> = stateFlowMutator( | |
scope = scope, | |
initialState = State(...), | |
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 2000), | |
transform = { actions -> | |
merge( | |
appMutator.navRailStatusMutations(), | |
actions.toMutationStream { | |
when (val action = type()) { | |
is Action.Fetch -> action.flow.fetchMutations(repo = repo) | |
is Action.Navigate -> action.flow.map { it.navAction }.consumeWith(appMutator) | |
is Action.UpdateListState -> action.flow.updateListStateMutations() | |
is Action.FilterChanged -> action.flow.filterChangedMutations() | |
is Action.ToggleFilter -> action.flow.filterToggleMutations() | |
is Action.GridSize -> action.flow.gridSizeMutations() | |
} | |
} | |
).monitorWhenActive(appMutator) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment