Skip to content

Commit af5ae21

Browse files
stephencelismbrandonwMatejkobjessetipton
authored
Cache store scoping when possible (#2527)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Silence test warnings * wip * wip * wip * wip * wip * wip * wip * Revert "wip" This reverts commit ed6cc24. * Revert "Revert "wip"" This reverts commit 8358990. * wip * wip * wip * wip * wip * update a bunch of docs * wip * wip * wip * fix * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Kill integration tests for now * wip * wip * wip * wip * updating docs for @Reducer macro * replaced more Reducer protocols with @Reducer * Fixed some broken docc references * wip * Some @Reducer docs * more docs * convert some old styles to new style * wip * wip * wip * wip * wip * wip * wip * bump * update tutorials to use body * update tutorials to use DML on destination state enum * Add diagnostic * wip * updated a few more tests * wip * wip * Add another gotcha * wip * wip * wip * Add dynamic lookup to presentation state/action * wip * wip * Better lookup * wip * wip * wip * IdentifiedAction * wip * wip * wip * wip * wip * wip * wip * wip * wip * fixes * wip * wip * added migration guide for new scope operation * migration guide for new navigation view modifiers * wip * fix * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * wip * wip * remove for now * wip * wip * simplify scope * wip * updated some docs * migration guides * more migration guide * fix ci * fix * soft deprecate all apis using AnyCasePath * wip * Fix * fix tests * updated tests * swift-format 509 compatibility * wip * wip * Update Sources/ComposableArchitecture/Macros.swift Co-authored-by: Mateusz Bąk <[email protected]> * wip * wip * update optional state case study * remove initializer * Don't use @State for BasicsView integration demo * fix tests * remove reduce diagnostics for now * diagnose error not warning * Update Sources/ComposableArchitecture/Macros.swift Co-authored-by: Jesse Tipton <[email protected]> * wip * move integration tests to cron * Revert "move integration tests to cron" This reverts commit f9bdf2f. * disable flakey tests on CI * wip * wip * fix migration guide * fix docs * fix deprecation messages * wip * wip * missing deprecation * soft * wip * update migration guide * Fix resolved * update migration guide * fix test * format * wip * fix * wip * wip * wip * wip * wip * wip * wip * wip * fix * wip * wip --------- Co-authored-by: Brandon Williams <[email protected]> Co-authored-by: Mateusz Bąk <[email protected]> Co-authored-by: Brandon Williams <[email protected]> Co-authored-by: Jesse Tipton <[email protected]>
1 parent a384c00 commit af5ae21

File tree

97 files changed

+1242
-587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1242
-587
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-AlertsAndConfirmationDialogs.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ struct AlertAndConfirmationDialogView: View {
124124
}
125125
.navigationTitle("Alerts & Dialogs")
126126
.alert(
127-
store: self.store.scope(state: \.$alert, action: { .alert($0) })
127+
store: self.store.scope(state: \.$alert, action: \.alert)
128128
)
129129
.confirmationDialog(
130-
store: self.store.scope(state: \.$confirmationDialog, action: { .confirmationDialog($0) })
130+
store: self.store.scope(state: \.$confirmationDialog, action: \.confirmationDialog)
131131
)
132132
}
133133
}

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Animations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct AnimationsView: View {
147147
Button("Reset") { viewStore.send(.resetButtonTapped) }
148148
.padding([.horizontal, .bottom])
149149
}
150-
.alert(store: self.store.scope(state: \.$alert, action: { .alert($0) }))
150+
.alert(store: self.store.scope(state: \.$alert, action: \.alert))
151151
.navigationBarTitleDisplayMode(.inline)
152152
}
153153
}

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Composition-TwoCounters.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ struct TwoCountersView: View {
4747
HStack {
4848
Text("Counter 1")
4949
Spacer()
50-
CounterView(store: self.store.scope(state: \.counter1, action: { .counter1($0) }))
50+
CounterView(store: self.store.scope(state: \.counter1, action: \.counter1))
5151
}
5252

5353
HStack {
5454
Text("Counter 2")
5555
Spacer()
56-
CounterView(store: self.store.scope(state: \.counter2, action: { .counter2($0) }))
56+
CounterView(store: self.store.scope(state: \.counter2, action: \.counter2))
5757
}
5858
}
5959
.buttonStyle(.borderless)

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-OptionalState.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ private let readMe = """
55
This screen demonstrates how to show and hide views based on the presence of some optional child \
66
state.
77
8-
The parent state holds a `CounterState?` value. When it is `nil` we will default to a plain text \
8+
The parent state holds a `Counter.State?` value. When it is `nil` we will default to a plain text \
99
view. But when it is non-`nil` we will show a view fragment for a counter that operates on the \
1010
non-optional counter state.
1111
@@ -62,14 +62,14 @@ struct OptionalBasicsView: View {
6262
}
6363

6464
IfLetStore(
65-
self.store.scope(state: \.optionalCounter, action: { .optionalCounter($0) })
65+
self.store.scope(state: \.optionalCounter, action: \.optionalCounter)
6666
) { store in
67-
Text(template: "`CounterState` is non-`nil`")
67+
Text(template: "`Counter.State` is non-`nil`")
6868
CounterView(store: store)
6969
.buttonStyle(.borderless)
7070
.frame(maxWidth: .infinity)
7171
} else: {
72-
Text(template: "`CounterState` is `nil`")
72+
Text(template: "`Counter.State` is `nil`")
7373
}
7474
}
7575
.navigationTitle("Optional state")

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-SharedState.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ struct SharedStateView: View {
180180

181181
if viewStore.state == .counter {
182182
SharedStateCounterView(
183-
store: self.store.scope(state: \.counter, action: { .counter($0) })
183+
store: self.store.scope(state: \.counter, action: \.counter)
184184
)
185185
}
186186

187187
if viewStore.state == .profile {
188188
SharedStateProfileView(
189-
store: self.store.scope(state: \.profile, action: { .profile($0) })
189+
store: self.store.scope(state: \.profile, action: \.profile)
190190
)
191191
}
192192

@@ -228,7 +228,7 @@ struct SharedStateCounterView: View {
228228
}
229229
.padding(.top)
230230
.navigationTitle("Shared State Demo")
231-
.alert(store: self.store.scope(state: \.$alert, action: { .alert($0) }))
231+
.alert(store: self.store.scope(state: \.$alert, action: \.alert))
232232
}
233233
}
234234
}

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-WebSocket.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct WebSocketView: View {
186186
Text("Received messages")
187187
}
188188
}
189-
.alert(store: self.store.scope(state: \.$alert, action: { .alert($0) }))
189+
.alert(store: self.store.scope(state: \.$alert, action: \.alert))
190190
.navigationTitle("Web Socket")
191191
}
192192
}

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Lists-NavigateAndLoad.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct NavigateAndLoadListView: View {
9393
send: { .setNavigation(selection: $0) }
9494
)
9595
) {
96-
IfLetStore(self.store.scope(state: \.selection?.value, action: { .counter($0) })) {
96+
IfLetStore(self.store.scope(state: \.selection?.value, action: \.counter)) {
9797
CounterView(store: $0)
9898
} else: {
9999
ProgressView()

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Multiple-Destinations.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,17 @@ struct MultipleDestinationsView: View {
9090
}
9191
}
9292
.navigationDestination(
93-
store: self.store.scope(state: \.$destination, action: { .destination($0) }),
94-
state: \.drillDown,
95-
action: { .drillDown($0) }
93+
store: self.store.scope(state: \.$destination.drillDown, action: \.destination.drillDown)
9694
) { store in
9795
CounterView(store: store)
9896
}
9997
.popover(
100-
store: self.store.scope(state: \.$destination, action: { .destination($0) }),
101-
state: \.popover,
102-
action: { .popover($0) }
98+
store: self.store.scope(state: \.$destination.popover, action: \.destination.popover)
10399
) { store in
104100
CounterView(store: store)
105101
}
106102
.sheet(
107-
store: self.store.scope(state: \.$destination, action: { .destination($0) }),
108-
state: \.sheet,
109-
action: { .sheet($0) }
103+
store: self.store.scope(state: \.$destination.sheet, action: \.destination.sheet)
110104
) { store in
111105
CounterView(store: store)
112106
}

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-NavigateAndLoad.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct NavigateAndLoadView: View {
7777
)
7878
) {
7979
IfLetStore(
80-
self.store.scope(state: \.optionalCounter, action: { .optionalCounter($0) })
80+
self.store.scope(state: \.optionalCounter, action: \.optionalCounter)
8181
) {
8282
CounterView(store: $0)
8383
} else: {

0 commit comments

Comments
 (0)