@@ -55,18 +55,18 @@ import SwiftUI
55
55
/// case of an enum in reducers that operate on the entire enum.
56
56
public struct SwitchStore < State, Action, Content: View > : View {
57
57
public let store : Store < State , Action >
58
- public let content : ( ) -> Content
58
+ public let content : Content
59
59
60
60
init (
61
61
store: Store < State , Action > ,
62
- @ViewBuilder content: @escaping ( ) -> Content
62
+ @ViewBuilder content: ( ) -> Content
63
63
) {
64
64
self . store = store
65
- self . content = content
65
+ self . content = content ( )
66
66
}
67
67
68
68
public var body : some View {
69
- self . content ( )
69
+ self . content
70
70
. environmentObject ( StoreObservableObject ( store: self . store) )
71
71
}
72
72
}
@@ -135,26 +135,26 @@ extension CaseLet where EnumAction == CaseAction {
135
135
/// a ``CaseLet`` for each case of the enum), then you must insert a ``Default`` view at the end of
136
136
/// the ``SwitchStore``'s body.
137
137
public struct Default < Content: View > : View {
138
- private let content : ( ) -> Content
138
+ private let content : Content
139
139
140
140
/// Initializes a ``Default`` view that computes content depending on if a store of enum state
141
141
/// does not match a particular case.
142
142
///
143
143
/// - Parameter content: A function that returns a view that is visible only when the switch
144
144
/// store's state does not match a preceding ``CaseLet`` view.
145
- public init ( @ViewBuilder content: @escaping ( ) -> Content ) {
146
- self . content = content
145
+ public init ( @ViewBuilder content: ( ) -> Content ) {
146
+ self . content = content ( )
147
147
}
148
148
149
149
public var body : some View {
150
- self . content ( )
150
+ self . content
151
151
}
152
152
}
153
153
154
154
extension SwitchStore {
155
155
public init < State1, Action1, Content1, DefaultContent> (
156
156
_ store: Store < State , Action > ,
157
- @ViewBuilder content: @escaping ( ) -> TupleView <
157
+ @ViewBuilder content: ( ) -> TupleView <
158
158
(
159
159
CaseLet < State , Action , State1 , Action1 , Content1 > ,
160
160
Default < DefaultContent >
@@ -171,8 +171,8 @@ extension SwitchStore {
171
171
>
172
172
>
173
173
{
174
+ let content = content ( ) . value
174
175
self . init ( store: store) {
175
- let content = content ( ) . value
176
176
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
177
177
if content. 0 . toCaseState ( viewStore. state) != nil {
178
178
content. 0
@@ -208,7 +208,7 @@ extension SwitchStore {
208
208
209
209
public init < State1, Action1, Content1, State2, Action2, Content2, DefaultContent> (
210
210
_ store: Store < State , Action > ,
211
- @ViewBuilder content: @escaping ( ) -> TupleView <
211
+ @ViewBuilder content: ( ) -> TupleView <
212
212
(
213
213
CaseLet < State , Action , State1 , Action1 , Content1 > ,
214
214
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -229,8 +229,8 @@ extension SwitchStore {
229
229
>
230
230
>
231
231
{
232
+ let content = content ( ) . value
232
233
self . init ( store: store) {
233
- let content = content ( ) . value
234
234
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
235
235
if content. 0 . toCaseState ( viewStore. state) != nil {
236
236
content. 0
@@ -248,7 +248,7 @@ extension SwitchStore {
248
248
file: StaticString = #file,
249
249
fileID: StaticString = #fileID,
250
250
line: UInt = #line,
251
- @ViewBuilder content: @escaping ( ) -> TupleView <
251
+ @ViewBuilder content: ( ) -> TupleView <
252
252
(
253
253
CaseLet < State , Action , State1 , Action1 , Content1 > ,
254
254
CaseLet < State , Action , State2 , Action2 , Content2 >
@@ -283,7 +283,7 @@ extension SwitchStore {
283
283
DefaultContent
284
284
> (
285
285
_ store: Store < State , Action > ,
286
- @ViewBuilder content: @escaping ( ) -> TupleView <
286
+ @ViewBuilder content: ( ) -> TupleView <
287
287
(
288
288
CaseLet < State , Action , State1 , Action1 , Content1 > ,
289
289
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -308,8 +308,8 @@ extension SwitchStore {
308
308
>
309
309
>
310
310
{
311
+ let content = content ( ) . value
311
312
self . init ( store: store) {
312
- let content = content ( ) . value
313
313
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
314
314
if content. 0 . toCaseState ( viewStore. state) != nil {
315
315
content. 0
@@ -329,7 +329,7 @@ extension SwitchStore {
329
329
file: StaticString = #file,
330
330
fileID: StaticString = #fileID,
331
331
line: UInt = #line,
332
- @ViewBuilder content: @escaping ( ) -> TupleView <
332
+ @ViewBuilder content: ( ) -> TupleView <
333
333
(
334
334
CaseLet < State , Action , State1 , Action1 , Content1 > ,
335
335
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -370,7 +370,7 @@ extension SwitchStore {
370
370
DefaultContent
371
371
> (
372
372
_ store: Store < State , Action > ,
373
- @ViewBuilder content: @escaping ( ) -> TupleView <
373
+ @ViewBuilder content: ( ) -> TupleView <
374
374
(
375
375
CaseLet < State , Action , State1 , Action1 , Content1 > ,
376
376
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -399,8 +399,8 @@ extension SwitchStore {
399
399
>
400
400
>
401
401
{
402
+ let content = content ( ) . value
402
403
self . init ( store: store) {
403
- let content = content ( ) . value
404
404
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
405
405
if content. 0 . toCaseState ( viewStore. state) != nil {
406
406
content. 0
@@ -427,7 +427,7 @@ extension SwitchStore {
427
427
file: StaticString = #file,
428
428
fileID: StaticString = #fileID,
429
429
line: UInt = #line,
430
- @ViewBuilder content: @escaping ( ) -> TupleView <
430
+ @ViewBuilder content: ( ) -> TupleView <
431
431
(
432
432
CaseLet < State , Action , State1 , Action1 , Content1 > ,
433
433
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -474,7 +474,7 @@ extension SwitchStore {
474
474
DefaultContent
475
475
> (
476
476
_ store: Store < State , Action > ,
477
- @ViewBuilder content: @escaping ( ) -> TupleView <
477
+ @ViewBuilder content: ( ) -> TupleView <
478
478
(
479
479
CaseLet < State , Action , State1 , Action1 , Content1 > ,
480
480
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -507,8 +507,8 @@ extension SwitchStore {
507
507
>
508
508
>
509
509
{
510
+ let content = content ( ) . value
510
511
self . init ( store: store) {
511
- let content = content ( ) . value
512
512
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
513
513
if content. 0 . toCaseState ( viewStore. state) != nil {
514
514
content. 0
@@ -538,7 +538,7 @@ extension SwitchStore {
538
538
file: StaticString = #file,
539
539
fileID: StaticString = #fileID,
540
540
line: UInt = #line,
541
- @ViewBuilder content: @escaping ( ) -> TupleView <
541
+ @ViewBuilder content: ( ) -> TupleView <
542
542
(
543
543
CaseLet < State , Action , State1 , Action1 , Content1 > ,
544
544
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -591,7 +591,7 @@ extension SwitchStore {
591
591
DefaultContent
592
592
> (
593
593
_ store: Store < State , Action > ,
594
- @ViewBuilder content: @escaping ( ) -> TupleView <
594
+ @ViewBuilder content: ( ) -> TupleView <
595
595
(
596
596
CaseLet < State , Action , State1 , Action1 , Content1 > ,
597
597
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -628,8 +628,8 @@ extension SwitchStore {
628
628
>
629
629
>
630
630
{
631
+ let content = content ( ) . value
631
632
self . init ( store: store) {
632
- let content = content ( ) . value
633
633
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
634
634
if content. 0 . toCaseState ( viewStore. state) != nil {
635
635
content. 0
@@ -662,7 +662,7 @@ extension SwitchStore {
662
662
file: StaticString = #file,
663
663
fileID: StaticString = #fileID,
664
664
line: UInt = #line,
665
- @ViewBuilder content: @escaping ( ) -> TupleView <
665
+ @ViewBuilder content: ( ) -> TupleView <
666
666
(
667
667
CaseLet < State , Action , State1 , Action1 , Content1 > ,
668
668
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -721,7 +721,7 @@ extension SwitchStore {
721
721
DefaultContent
722
722
> (
723
723
_ store: Store < State , Action > ,
724
- @ViewBuilder content: @escaping ( ) -> TupleView <
724
+ @ViewBuilder content: ( ) -> TupleView <
725
725
(
726
726
CaseLet < State , Action , State1 , Action1 , Content1 > ,
727
727
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -762,8 +762,8 @@ extension SwitchStore {
762
762
>
763
763
>
764
764
{
765
+ let content = content ( ) . value
765
766
self . init ( store: store) {
766
- let content = content ( ) . value
767
767
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
768
768
if content. 0 . toCaseState ( viewStore. state) != nil {
769
769
content. 0
@@ -799,7 +799,7 @@ extension SwitchStore {
799
799
file: StaticString = #file,
800
800
fileID: StaticString = #fileID,
801
801
line: UInt = #line,
802
- @ViewBuilder content: @escaping ( ) -> TupleView <
802
+ @ViewBuilder content: ( ) -> TupleView <
803
803
(
804
804
CaseLet < State , Action , State1 , Action1 , Content1 > ,
805
805
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -864,7 +864,7 @@ extension SwitchStore {
864
864
DefaultContent
865
865
> (
866
866
_ store: Store < State , Action > ,
867
- @ViewBuilder content: @escaping ( ) -> TupleView <
867
+ @ViewBuilder content: ( ) -> TupleView <
868
868
(
869
869
CaseLet < State , Action , State1 , Action1 , Content1 > ,
870
870
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -909,8 +909,8 @@ extension SwitchStore {
909
909
>
910
910
>
911
911
{
912
+ let content = content ( ) . value
912
913
self . init ( store: store) {
913
- let content = content ( ) . value
914
914
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
915
915
if content. 0 . toCaseState ( viewStore. state) != nil {
916
916
content. 0
@@ -949,7 +949,7 @@ extension SwitchStore {
949
949
file: StaticString = #file,
950
950
fileID: StaticString = #fileID,
951
951
line: UInt = #line,
952
- @ViewBuilder content: @escaping ( ) -> TupleView <
952
+ @ViewBuilder content: ( ) -> TupleView <
953
953
(
954
954
CaseLet < State , Action , State1 , Action1 , Content1 > ,
955
955
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -1020,7 +1020,7 @@ extension SwitchStore {
1020
1020
DefaultContent
1021
1021
> (
1022
1022
_ store: Store < State , Action > ,
1023
- @ViewBuilder content: @escaping ( ) -> TupleView <
1023
+ @ViewBuilder content: ( ) -> TupleView <
1024
1024
(
1025
1025
CaseLet < State , Action , State1 , Action1 , Content1 > ,
1026
1026
CaseLet < State , Action , State2 , Action2 , Content2 > ,
@@ -1069,8 +1069,8 @@ extension SwitchStore {
1069
1069
>
1070
1070
>
1071
1071
{
1072
+ let content = content ( ) . value
1072
1073
self . init ( store: store) {
1073
- let content = content ( ) . value
1074
1074
return WithViewStore ( store, removeDuplicates: { enumTag ( $0) == enumTag ( $1) } ) { viewStore in
1075
1075
if content. 0 . toCaseState ( viewStore. state) != nil {
1076
1076
content. 0
@@ -1112,7 +1112,7 @@ extension SwitchStore {
1112
1112
file: StaticString = #file,
1113
1113
fileID: StaticString = #fileID,
1114
1114
line: UInt = #line,
1115
- @ViewBuilder content: @escaping ( ) -> TupleView <
1115
+ @ViewBuilder content: ( ) -> TupleView <
1116
1116
(
1117
1117
CaseLet < State , Action , State1 , Action1 , Content1 > ,
1118
1118
CaseLet < State , Action , State2 , Action2 , Content2 > ,
0 commit comments