Skip to content

Instantly share code, notes, and snippets.

@atimca
Created June 19, 2020 09:16
Show Gist options
  • Save atimca/a4f23f03c49f2c21ccbef60087b5867b to your computer and use it in GitHub Desktop.
Save atimca/a4f23f03c49f2c21ccbef60087b5867b to your computer and use it in GitHub Desktop.
func transform(
newsReducer: @escaping (NewsState, NewsEvent) -> NewsState,
stateKeyPath: WritableKeyPath<AppState, NewsState>
) -> Reducer {
return { appState, appEvent in
var appState = appState
appState[keyPath: stateKeyPath] = newsReducer(appState[keyPath: stateKeyPath], appEvent)
return appState
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment