Update Tic-Tac-Toe to use enum state (#595)

* Update Tic-Tac-Toe to use enum state

* wip

* more swift compatability changes

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
This commit is contained in:
Stephen Celis
2021-06-14 09:39:39 -07:00
committed by GitHub
parent e1c0a52897
commit c99a2f9636
4 changed files with 41 additions and 43 deletions

View File

@@ -66,9 +66,9 @@ public struct SwitchStore<State, Action, Content>: View where Content: View {
public struct CaseLet<GlobalState, GlobalAction, LocalState, LocalAction, Content>: View
where Content: View {
@EnvironmentObject private var store: StoreObservableObject<GlobalState, GlobalAction>
let toLocalState: (GlobalState) -> LocalState?
let fromLocalAction: (LocalAction) -> GlobalAction
let content: (Store<LocalState, LocalAction>) -> Content
public let toLocalState: (GlobalState) -> LocalState?
public let fromLocalAction: (LocalAction) -> GlobalAction
public let content: (Store<LocalState, LocalAction>) -> Content
/// Initializes a `CaseLet` view that computes content depending on if a store of enum state
/// matches a particular case.
@@ -155,10 +155,9 @@ extension SwitchStore {
public init<State1, Action1, Content1>(
_ store: Store<State, Action>,
@ViewBuilder content: @escaping ()
-> CaseLet<State, Action, State1, Action1, Content1>,
file: StaticString = #file,
line: UInt = #line
line: UInt = #line,
@ViewBuilder content: @escaping () -> CaseLet<State, Action, State1, Action1, Content1>
)
where
Content == WithViewStore<
@@ -215,14 +214,14 @@ extension SwitchStore {
public init<State1, Action1, Content1, State2, Action2, Content2>(
_ store: Store<State, Action>,
file: StaticString = #file,
line: UInt = #line,
@ViewBuilder content: @escaping () -> TupleView<
(
CaseLet<State, Action, State1, Action1, Content1>,
CaseLet<State, Action, State2, Action2, Content2>
)
>,
file: StaticString = #file,
line: UInt = #line
>
)
where
Content == WithViewStore<
@@ -295,15 +294,15 @@ extension SwitchStore {
public init<State1, Action1, Content1, State2, Action2, Content2, State3, Action3, Content3>(
_ store: Store<State, Action>,
file: StaticString = #file,
line: UInt = #line,
@ViewBuilder content: @escaping () -> TupleView<
(
CaseLet<State, Action, State1, Action1, Content1>,
CaseLet<State, Action, State2, Action2, Content2>,
CaseLet<State, Action, State3, Action3, Content3>
)
>,
file: StaticString = #file,
line: UInt = #line
>
)
where
Content == WithViewStore<
@@ -392,6 +391,8 @@ extension SwitchStore {
State4, Action4, Content4
>(
_ store: Store<State, Action>,
file: StaticString = #file,
line: UInt = #line,
@ViewBuilder content: @escaping () -> TupleView<
(
CaseLet<State, Action, State1, Action1, Content1>,
@@ -399,9 +400,7 @@ extension SwitchStore {
CaseLet<State, Action, State3, Action3, Content3>,
CaseLet<State, Action, State4, Action4, Content4>
)
>,
file: StaticString = #file,
line: UInt = #line
>
)
where
Content == WithViewStore<
@@ -502,6 +501,8 @@ extension SwitchStore {
State5, Action5, Content5
>(
_ store: Store<State, Action>,
file: StaticString = #file,
line: UInt = #line,
@ViewBuilder content: @escaping () -> TupleView<
(
CaseLet<State, Action, State1, Action1, Content1>,
@@ -510,9 +511,7 @@ extension SwitchStore {
CaseLet<State, Action, State4, Action4, Content4>,
CaseLet<State, Action, State5, Action5, Content5>
)
>,
file: StaticString = #file,
line: UInt = #line
>
)
where
Content == WithViewStore<