Skip to content

Instantly share code, notes, and snippets.

@atimca
Created June 19, 2020 09:14
Show Gist options
  • Save atimca/ff1e6f33f30b46c1a873fa342093f560 to your computer and use it in GitHub Desktop.
Save atimca/ff1e6f33f30b46c1a873fa342093f560 to your computer and use it in GitHub Desktop.
func transform(
newsReducer: @escaping (NewsState, AppEvent) -> NewsState,
appStateIntoNews: @escaping (AppState) -> NewsState,
mutateAppStateWithNewsState: @escaping (AppState, NewsState) -> AppState
) -> Reducer {
return { appState, appEvent in
let newsState = appStateIntoNews(appState)
let newNewsState = newsReducer(newsState, appEvent)
return mutateAppStateWithNewsState(appState, newNewsState)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment