Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@finestructure
Last active April 14, 2020 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finestructure/52ab97094b05bf09a726fd6c2576402e to your computer and use it in GitHub Desktop.
Save finestructure/52ab97094b05bf09a726fd6c2576402e to your computer and use it in GitHub Desktop.
"Guidance protocols" for Composable Architecture
//
// CAProtocols.swift
// RequirementEditor
//
// Created by Sven A. Schmidt on 29/03/2020.
// Copyright © 2020 finestructure. All rights reserved.
//
import SwiftUI
import ComposableArchitecture
public protocol CAInitialStore {
associatedtype State
associatedtype Action
// FIXME: change to .live and .mock
static func initialStore() -> Store<State, Action>
}
public protocol CABasicView: View {
associatedtype State
associatedtype Action
var store: Store<State, Action> { get }
// Default:
// @ObservedObject public private(set) var store: Store<State, Action>
// public init(store: Store<State, Action> = Self.initialStore()) {
// self.store = store
// }
static var reducer: Reducer<State, Action, Void> { get }
// Default:
// public static let reducer = Reducer<State, Action, Void> { state, action, _ in .noop }
}
public protocol CABasicEnvView: View {
associatedtype State
associatedtype Action
associatedtype Environment
var store: Store<State, Action> { get }
// Default:
// @ObservedObject public var private(set) store: Store<State, Action>
// public init(store: Store<State, Action> = Self.initialStore()) {
// self.store = store
// }
static var reducer: Reducer<State, Action, Environment> { get }
// Default:
// public static let reducer = Reducer<State, Action, Environment> { state, action, env in .noop }
}
public protocol CASystemEnvView: View {
associatedtype State
associatedtype Action
associatedtype Environment
var store: Store<State, Action> { get }
// Default:
// @ObservedObject public var private(set) store: Store<State, Action>
// public init(store: Store<State, Action> = Self.initialStore()) {
// self.store = store
// }
static var reducer: Reducer<State, Action, SystemEnvironment<Environment>> { get }
// Default:
// public static let reducer = Reducer<State, Action, SystemEnvironment<Environment>> { state, action, env in .noop }
}
public protocol CAMock {
static var mock: Self { get }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment