Created
June 19, 2020 09:18
-
-
Save atimca/2b2e9d6c5258b5d3606d3305f9fc8d10 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func transform( | |
newsReducer: @escaping (NewsState, NewsEvent) -> NewsState, | |
stateKeyPath: WritableKeyPath<AppState, NewsState> | |
) -> Reducer { | |
return { appState, appEvent in | |
guard let newsEvent = appEvent.newsEvent else { return appState } | |
var appState = appState | |
appState[keyPath: stateKeyPath] = newsReducer(appState[keyPath: stateKeyPath], newsEvent) | |
return appState | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment