Created
August 15, 2022 09:52
-
-
Save pofat/540bc3443deb4c8ae0e67ace53aa5c6c to your computer and use it in GitHub Desktop.
TCA state-action-env-reducer-view code snippet
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
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