Skip to content

Commit 767231d

Browse files
Add Store.init that takes reducer builder (#2087)
* Add `Store.init` that takes reducer builder * wip * wip * added some tests * wip * wip * wip --------- Co-authored-by: Brandon Williams <[email protected]>
1 parent c096892 commit 767231d

File tree

119 files changed

+1365
-1424
lines changed

Some content is hidden

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

119 files changed

+1365
-1424
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,9 @@ struct RootView: View {
285285
struct RootView_Previews: PreviewProvider {
286286
static var previews: some View {
287287
RootView(
288-
store: Store(
289-
initialState: Root.State(),
290-
reducer: Root()
291-
)
288+
store: Store(initialState: Root.State()) {
289+
Root()
290+
}
292291
)
293292
}
294293
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ struct AlertAndConfirmationDialog_Previews: PreviewProvider {
128128
static var previews: some View {
129129
NavigationView {
130130
AlertAndConfirmationDialogView(
131-
store: Store(
132-
initialState: AlertAndConfirmationDialog.State(),
133-
reducer: AlertAndConfirmationDialog()
134-
)
131+
store: Store(initialState: AlertAndConfirmationDialog.State()) {
132+
AlertAndConfirmationDialog()
133+
}
135134
)
136135
}
137136
}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,17 @@ struct AnimationsView_Previews: PreviewProvider {
152152
Group {
153153
NavigationView {
154154
AnimationsView(
155-
store: Store(
156-
initialState: Animations.State(),
157-
reducer: Animations()
158-
)
155+
store: Store(initialState: Animations.State()) {
156+
Animations()
157+
}
159158
)
160159
}
161160

162161
NavigationView {
163162
AnimationsView(
164-
store: Store(
165-
initialState: Animations.State(),
166-
reducer: Animations()
167-
)
163+
store: Store(initialState: Animations.State()) {
164+
Animations()
165+
}
168166
)
169167
}
170168
.environment(\.colorScheme, .dark)

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Basics.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ struct BindingBasicsView_Previews: PreviewProvider {
129129
static var previews: some View {
130130
NavigationView {
131131
BindingBasicsView(
132-
store: Store(
133-
initialState: BindingBasics.State(),
134-
reducer: BindingBasics()
135-
)
132+
store: Store(initialState: BindingBasics.State()) {
133+
BindingBasics()
134+
}
136135
)
137136
}
138137
}

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@ struct BindingFormView_Previews: PreviewProvider {
116116
static var previews: some View {
117117
NavigationView {
118118
BindingFormView(
119-
store: Store(
120-
initialState: BindingForm.State(),
121-
reducer: BindingForm()
122-
)
119+
store: Store(initialState: BindingForm.State()) {
120+
BindingForm()
121+
}
123122
)
124123
}
125124
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ struct TwoCountersView_Previews: PreviewProvider {
6868
static var previews: some View {
6969
NavigationView {
7070
TwoCountersView(
71-
store: Store(
72-
initialState: TwoCounters.State(),
73-
reducer: TwoCounters()
74-
)
71+
store: Store(initialState: TwoCounters.State()) {
72+
TwoCounters()
73+
}
7574
)
7675
}
7776
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ struct CounterView_Previews: PreviewProvider {
8585
static var previews: some View {
8686
NavigationView {
8787
CounterDemoView(
88-
store: Store(
89-
initialState: Counter.State(),
90-
reducer: Counter()
91-
)
88+
store: Store(initialState: Counter.State()) {
89+
Counter()
90+
}
9291
)
9392
}
9493
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ struct FocusDemo_Previews: PreviewProvider {
8989
static var previews: some View {
9090
NavigationView {
9191
FocusDemoView(
92-
store: Store(
93-
initialState: FocusDemo.State(),
94-
reducer: FocusDemo()
95-
)
92+
store: Store(initialState: FocusDemo.State()) {
93+
FocusDemo()
94+
}
9695
)
9796
}
9897
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ struct OptionalBasicsView_Previews: PreviewProvider {
8787
Group {
8888
NavigationView {
8989
OptionalBasicsView(
90-
store: Store(
91-
initialState: OptionalBasics.State(),
92-
reducer: OptionalBasics()
93-
)
90+
store: Store(initialState: OptionalBasics.State()) {
91+
OptionalBasics()
92+
}
9493
)
9594
}
9695

9796
NavigationView {
9897
OptionalBasicsView(
9998
store: Store(
100-
initialState: OptionalBasics.State(optionalCounter: Counter.State(count: 42)),
101-
reducer: OptionalBasics()
102-
)
99+
initialState: OptionalBasics.State(optionalCounter: Counter.State(count: 42))
100+
) {
101+
OptionalBasics()
102+
}
103103
)
104104
}
105105
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,9 @@ struct SharedStateProfileView: View {
260260
struct SharedState_Previews: PreviewProvider {
261261
static var previews: some View {
262262
SharedStateView(
263-
store: Store(
264-
initialState: SharedState.State(),
265-
reducer: SharedState()
266-
)
263+
store: Store(initialState: SharedState.State()) {
264+
SharedState()
265+
}
267266
)
268267
}
269268
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,9 @@ struct EffectsBasicsView_Previews: PreviewProvider {
156156
static var previews: some View {
157157
NavigationView {
158158
EffectsBasicsView(
159-
store: Store(
160-
initialState: EffectsBasics.State(),
161-
reducer: EffectsBasics()
162-
)
159+
store: Store(initialState: EffectsBasics.State()) {
160+
EffectsBasics()
161+
}
163162
)
164163
}
165164
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ struct EffectsCancellation_Previews: PreviewProvider {
122122
static var previews: some View {
123123
NavigationView {
124124
EffectsCancellationView(
125-
store: Store(
126-
initialState: EffectsCancellation.State(),
127-
reducer: EffectsCancellation()
128-
)
125+
store: Store(initialState: EffectsCancellation.State()) {
126+
EffectsCancellation()
127+
}
129128
)
130129
}
131130
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ struct LongLivingEffectsView: View {
109109
struct EffectsLongLiving_Previews: PreviewProvider {
110110
static var previews: some View {
111111
let appView = LongLivingEffectsView(
112-
store: Store(
113-
initialState: LongLivingEffects.State(),
114-
reducer: LongLivingEffects()
115-
)
112+
store: Store(initialState: LongLivingEffects.State()) {
113+
LongLivingEffects()
114+
}
116115
)
117116

118117
return Group {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ struct RefreshableView: View {
118118
struct Refreshable_Previews: PreviewProvider {
119119
static var previews: some View {
120120
RefreshableView(
121-
store: Store(
122-
initialState: Refreshable.State(),
123-
reducer: Refreshable()
124-
)
121+
store: Store(initialState: Refreshable.State()) {
122+
Refreshable()
123+
}
125124
)
126125
}
127126
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,9 @@ struct TimersView_Previews: PreviewProvider {
120120
static var previews: some View {
121121
NavigationView {
122122
TimersView(
123-
store: Store(
124-
initialState: Timers.State(),
125-
reducer: Timers()
126-
)
123+
store: Store(initialState: Timers.State()) {
124+
Timers()
125+
}
127126
)
128127
}
129128
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,9 @@ struct WebSocketView_Previews: PreviewProvider {
356356
static var previews: some View {
357357
NavigationView {
358358
WebSocketView(
359-
store: Store(
360-
initialState: WebSocket.State(receivedMessages: ["Hi"]),
361-
reducer: WebSocket()
362-
)
359+
store: Store(initialState: WebSocket.State(receivedMessages: ["Hi"])) {
360+
WebSocket()
361+
}
363362
)
364363
}
365364
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ struct LoadThenNavigateListView_Previews: PreviewProvider {
136136
LoadThenNavigateList.State.Row(count: 42, id: UUID()),
137137
LoadThenNavigateList.State.Row(count: 100, id: UUID()),
138138
]
139-
),
140-
reducer: LoadThenNavigateList()
141-
)
139+
)
140+
) {
141+
LoadThenNavigateList()
142+
}
142143
)
143144
}
144145
.navigationViewStyle(.stack)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ struct NavigateAndLoadListView_Previews: PreviewProvider {
121121
NavigateAndLoadList.State.Row(count: 42, id: UUID()),
122122
NavigateAndLoadList.State.Row(count: 100, id: UUID()),
123123
]
124-
),
125-
reducer: NavigateAndLoadList()
126-
)
124+
)
125+
) {
126+
NavigateAndLoadList()
127+
}
127128
)
128129
}
129130
.navigationViewStyle(.stack)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ struct LoadThenNavigateView_Previews: PreviewProvider {
108108
static var previews: some View {
109109
NavigationView {
110110
LoadThenNavigateView(
111-
store: Store(
112-
initialState: LoadThenNavigate.State(),
113-
reducer: LoadThenNavigate()
114-
)
111+
store: Store(initialState: LoadThenNavigate.State()) {
112+
LoadThenNavigate()
113+
}
115114
)
116115
}
117116
.navigationViewStyle(.stack)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ struct NavigateAndLoadView_Previews: PreviewProvider {
9696
static var previews: some View {
9797
NavigationView {
9898
NavigateAndLoadView(
99-
store: Store(
100-
initialState: NavigateAndLoad.State(),
101-
reducer: NavigateAndLoad()
102-
)
99+
store: Store(initialState: NavigateAndLoad.State()) {
100+
NavigateAndLoad()
101+
}
103102
)
104103
}
105104
.navigationViewStyle(.stack)

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Sheet-LoadThenPresent.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ struct LoadThenPresentView_Previews: PreviewProvider {
110110
static var previews: some View {
111111
NavigationView {
112112
LoadThenPresentView(
113-
store: Store(
114-
initialState: LoadThenPresent.State(),
115-
reducer: LoadThenPresent()
116-
)
113+
store: Store(initialState: LoadThenPresent.State()) {
114+
LoadThenPresent()
115+
}
117116
)
118117
}
119118
}

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Sheet-PresentAndLoad.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ struct PresentAndLoadView_Previews: PreviewProvider {
9898
static var previews: some View {
9999
NavigationView {
100100
PresentAndLoadView(
101-
store: Store(
102-
initialState: PresentAndLoad.State(),
103-
reducer: PresentAndLoad()
104-
)
101+
store: Store(initialState: PresentAndLoad.State()) {
102+
PresentAndLoad()
103+
}
105104
)
106105
}
107106
}

Examples/CaseStudies/SwiftUICaseStudies/04-HigherOrderReducers-Lifecycle.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ struct Lifecycle_Previews: PreviewProvider {
170170
Group {
171171
NavigationView {
172172
LifecycleDemoView(
173-
store: Store(
174-
initialState: LifecycleDemo.State(),
175-
reducer: LifecycleDemo()
176-
)
173+
store: Store(initialState: LifecycleDemo.State()) {
174+
LifecycleDemo()
175+
}
177176
)
178177
}
179178
}

Examples/CaseStudies/SwiftUICaseStudies/04-HigherOrderReducers-Recursion.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,9 @@ struct NestedView_Previews: PreviewProvider {
125125
static var previews: some View {
126126
NavigationView {
127127
NestedView(
128-
store: Store(
129-
initialState: .mock,
130-
reducer: Nested()
131-
)
128+
store: Store(initialState: .mock) {
129+
Nested()
130+
}
132131
)
133132
}
134133
}

0 commit comments

Comments
 (0)