Skip to content

Instantly share code, notes, and snippets.

@pofat
Created August 15, 2022 09:52
  • 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 pofat/540bc3443deb4c8ae0e67ace53aa5c6c to your computer and use it in GitHub Desktop.
TCA state-action-env-reducer-view code snippet
import ComposableArchitecture
import SwiftUI
struct <#Name#>State: Equatable {}
enum <#Name#>Action: Equatable {}
struct <#Name#>Environment {}
extension <#Name#>Environment {
static var live = Self()
}
let <#Name#>Reducer = Reducer<
<#Name#>State,
<#Name#>Action,
<#Name#>Environment
> { state, action, environment in
.none
}
struct <#Name#>View: View {
typealias ViewStoreType = ViewStore<<#Name#>State, <#Name#>Action>
let store: Store<<#Name#>State, <#Name#>Action>
var body: some View {
WithViewStore(store) { viewStore in
}
}
}
#if DEBUG
struct <#Name#>View_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
<#Name#>View(store: .init(
initialState: .init(),
reducer: <#Name#>Reducer,
environment: .live
))
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment