Skip to content

Commit daf41b3

Browse files
authored
Add public Store.send and Store.withValue (#2222)
1 parent 95d2bc7 commit daf41b3

File tree

21 files changed

+93
-82
lines changed

21 files changed

+93
-82
lines changed

Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ struct RootView: View {
285285
}
286286
}
287287
.navigationTitle("Case Studies")
288-
.onAppear { ViewStore(self.store).send(.onAppear) }
288+
.onAppear { self.store.send(.onAppear) }
289289
}
290290
}
291291
}

Examples/CaseStudies/SwiftUICaseStudies/03-NavigationStack.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct NavigationDemoView: View {
112112

113113
Section {
114114
Button("Go to A → B → C") {
115-
ViewStore(self.store.stateless).send(.goToABCButtonTapped)
115+
self.store.send(.goToABCButtonTapped)
116116
}
117117
}
118118
}
@@ -364,7 +364,7 @@ struct ScreenBView: View {
364364
let store: StoreOf<ScreenB>
365365

366366
var body: some View {
367-
WithViewStore(self.store) { viewStore in
367+
WithViewStore(self.store, observe: { $0 }) { viewStore in
368368
Form {
369369
Section {
370370
Text(

Examples/CaseStudies/UIKitCaseStudies/CounterViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class CounterViewController: UIViewController {
3131
private var cancellables: Set<AnyCancellable> = []
3232

3333
init(store: StoreOf<Counter>) {
34-
self.viewStore = ViewStore(store)
34+
self.viewStore = ViewStore(store, observe: { $0 })
3535
super.init(nibName: nil, bundle: nil)
3636
}
3737

Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class CountersTableViewController: UITableViewController {
2929

3030
init(store: StoreOf<CounterList>) {
3131
self.store = store
32-
self.viewStore = ViewStore(store)
32+
self.viewStore = ViewStore(store, observe: { $0 })
3333
super.init(nibName: nil, bundle: nil)
3434
}
3535

Examples/CaseStudies/UIKitCaseStudies/LoadThenNavigate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class LazyNavigationViewController: UIViewController {
5959

6060
init(store: StoreOf<LazyNavigation>) {
6161
self.store = store
62-
self.viewStore = ViewStore(store)
62+
self.viewStore = ViewStore(store, observe: { $0 })
6363
super.init(nibName: nil, bundle: nil)
6464
}
6565

Examples/CaseStudies/UIKitCaseStudies/NavigateAndLoad.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class EagerNavigationViewController: UIViewController {
5555

5656
init(store: StoreOf<EagerNavigation>) {
5757
self.store = store
58-
self.viewStore = ViewStore(store)
58+
self.viewStore = ViewStore(store, observe: { $0 })
5959
super.init(nibName: nil, bundle: nil)
6060
}
6161

Examples/Integration/Integration/BindingLocalTestCase.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ struct BindingLocalTestCaseView: View {
8888
NavigationStackStore(self.store.scope(state: \.path, action: { .path($0) })) {
8989
VStack {
9090
Button("Full-screen-cover") {
91-
ViewStore(self.store.stateless).send(.fullScreenCoverButtonTapped)
91+
self.store.send(.fullScreenCoverButtonTapped)
9292
}
9393
Button("Navigation destination") {
94-
ViewStore(self.store.stateless).send(.navigationDestinationButtonTapped)
94+
self.store.send(.navigationDestinationButtonTapped)
9595
}
9696
NavigationLink("Path", state: Child.State())
9797
Button("Popover") {
98-
ViewStore(self.store.stateless).send(.popoverButtonTapped)
98+
self.store.send(.popoverButtonTapped)
9999
}
100100
Button("Sheet") {
101-
ViewStore(self.store.stateless).send(.sheetButtonTapped)
101+
self.store.send(.sheetButtonTapped)
102102
}
103103
}
104104
.fullScreenCover(

Examples/Integration/Integration/NavigationStackBindingTestCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct NavigationStackBindingTestCaseView: View {
3131
}
3232

3333
var body: some View {
34-
WithViewStore(store) { viewStore in
34+
WithViewStore(self.store) { viewStore in
3535
NavigationStack(
3636
path: viewStore.binding(
3737
get: \.path,

Examples/Integration/Integration/PresentationItemTestCase.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ struct PresentationItemTestCaseView: View {
7272
@ViewBuilder
7373
var core: some View {
7474
Button("Child A") {
75-
ViewStore(self.store.stateless).send(.childAButtonTapped)
75+
self.store.send(.childAButtonTapped)
7676
}
7777
Button("Child B") {
78-
ViewStore(self.store.stateless).send(.childBButtonTapped)
78+
self.store.send(.childBButtonTapped)
7979
}
8080
}
8181

@@ -97,7 +97,7 @@ struct PresentationItemTestCaseView: View {
9797
) { store in
9898
Text("Child A")
9999
Button("Swap") {
100-
ViewStore(store.stateless).send(.swapButtonTapped)
100+
store.send(.swapButtonTapped)
101101
}
102102
}
103103
case .childB:
@@ -107,7 +107,7 @@ struct PresentationItemTestCaseView: View {
107107
) { store in
108108
Text("Child B")
109109
Button("Swap") {
110-
ViewStore(store.stateless).send(.swapButtonTapped)
110+
store.send(.swapButtonTapped)
111111
}
112112
}
113113
}
@@ -125,7 +125,7 @@ struct PresentationItemTestCaseView: View {
125125
) { store in
126126
Text("Child A")
127127
Button("Swap") {
128-
ViewStore(store.stateless).send(.swapButtonTapped)
128+
store.send(.swapButtonTapped)
129129
}
130130
}
131131
.sheet(
@@ -135,7 +135,7 @@ struct PresentationItemTestCaseView: View {
135135
) { store in
136136
Text("Child B")
137137
Button("Swap") {
138-
ViewStore(store.stateless).send(.swapButtonTapped)
138+
store.send(.swapButtonTapped)
139139
}
140140
}
141141
}

Examples/Integration/Integration/SwitchStoreTestCase.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ struct SwitchStoreTestCaseView: View {
6060
}
6161

6262
var body: some View {
63-
WithViewStore(store.stateless) { viewStore in
64-
Button("Swap") { viewStore.send(.swap) }
65-
}
63+
Button("Swap") { self.store.send(.swap) }
6664
SwitchStore(self.store) {
6765
switch $0 {
6866
case .screenA:

0 commit comments

Comments
 (0)