Skip to content

Commit d6d81fa

Browse files
committed
ViewStore producer API improvements
- deprecated `viewStore.producer` made public - tests&examples fixed
1 parent 5d1d382 commit d6d81fa

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

Examples/CaseStudies/UIKitCaseStudies/CounterViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ final class CounterViewController: UIViewController {
6666
rootStackView.centerYAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.centerYAnchor),
6767
])
6868

69-
self.viewStore.producer.count
69+
self.viewStore.produced.count
7070
.map(String.init)
7171
.assign(to: \.text, on: countLabel)
7272
}

Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift

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

4848
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
4949

50-
self.viewStore.producer.counters
50+
self.viewStore.produced.counters
5151
.startWithValues({ [weak self] in self?.dataSource = $0 })
5252
}
5353

Examples/CaseStudies/UIKitCaseStudies/LoadThenNavigate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class LazyNavigationViewController: UIViewController {
8888
rootStackView.centerYAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.centerYAnchor),
8989
])
9090

91-
self.viewStore.producer.isActivityIndicatorHidden
91+
self.viewStore.produced.isActivityIndicatorHidden
9292
.assign(to: \.isHidden, on: activityIndicator)
9393

9494
self.store

Examples/CaseStudies/UIKitCaseStudies/NavigateAndLoad.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class EagerNavigationViewController: UIViewController {
8080
button.centerYAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.centerYAnchor),
8181
])
8282

83-
self.viewStore.producer.isNavigationActive.startWithValues { [weak self] isNavigationActive in
83+
self.viewStore.produced.isNavigationActive.startWithValues { [weak self] isNavigationActive in
8484
guard let self = self else { return }
8585
if isNavigationActive {
8686
self.navigationController?.pushViewController(

Examples/TicTacToe/Sources/Views-UIKit/GameViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ public final class GameViewController: UIViewController {
116116
])
117117
}
118118

119-
self.viewStore.producer.title
119+
self.viewStore.produced.title
120120
.assign(to: \.text, on: titleLabel)
121121

122-
self.viewStore.producer.isPlayAgainButtonHidden
122+
self.viewStore.produced.isPlayAgainButtonHidden
123123
.assign(to: \.isHidden, on: playAgainButton)
124124

125-
self.viewStore.producer.producer.map { ($0.board, $0.isGameEnabled) }
125+
self.viewStore.produced.producer.map { ($0.board, $0.isGameEnabled) }
126126
.skipRepeats(==)
127127
.startWithValues { board, isGameEnabled in
128128
board.enumerated().forEach { rowIdx, row in

Examples/TicTacToe/Sources/Views-UIKit/LoginViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,25 @@ class LoginViewController: UIViewController {
105105
divider.heightAnchor.constraint(equalToConstant: 1),
106106
])
107107

108-
self.viewStore.producer.isLoginButtonEnabled
108+
self.viewStore.produced.isLoginButtonEnabled
109109
.assign(to: \.isEnabled, on: loginButton)
110110

111-
self.viewStore.producer.email
111+
self.viewStore.produced.email
112112
.assign(to: \.text, on: emailTextField)
113113

114-
self.viewStore.producer.isEmailTextFieldEnabled
114+
self.viewStore.produced.isEmailTextFieldEnabled
115115
.assign(to: \.isEnabled, on: emailTextField)
116116

117-
self.viewStore.producer.password
117+
self.viewStore.produced.password
118118
.assign(to: \.text, on: passwordTextField)
119119

120-
self.viewStore.producer.isPasswordTextFieldEnabled
120+
self.viewStore.produced.isPasswordTextFieldEnabled
121121
.assign(to: \.isEnabled, on: passwordTextField)
122122

123-
self.viewStore.producer.isActivityIndicatorHidden
123+
self.viewStore.produced.isActivityIndicatorHidden
124124
.assign(to: \.isHidden, on: activityIndicator)
125125

126-
self.viewStore.producer.alert
126+
self.viewStore.produced.alert
127127
.startWithValues { [weak self] alert in
128128
guard let self = self else { return }
129129
guard let alert = alert else { return }

Examples/TicTacToe/Sources/Views-UIKit/NewGameViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ class NewGameViewController: UIViewController {
101101
rootStackView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
102102
])
103103

104-
self.viewStore.producer.isLetsPlayButtonEnabled
104+
self.viewStore.produced.isLetsPlayButtonEnabled
105105
.assign(to: \.isEnabled, on: letsPlayButton)
106106

107-
self.viewStore.producer.oPlayerName
107+
self.viewStore.produced.oPlayerName
108108
.assign(to: \.text, on: playerOTextField)
109109

110-
self.viewStore.producer.xPlayerName
110+
self.viewStore.produced.xPlayerName
111111
.assign(to: \.text, on: playerXTextField)
112112

113113
self.store

Examples/TicTacToe/Sources/Views-UIKit/TwoFactorViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ public final class TwoFactorViewController: UIViewController {
7373
rootStackView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
7474
])
7575

76-
self.viewStore.producer.isActivityIndicatorHidden
76+
self.viewStore.produced.isActivityIndicatorHidden
7777
.assign(to: \.isHidden, on: activityIndicator)
7878

79-
self.viewStore.producer.code
79+
self.viewStore.produced.code
8080
.assign(to: \.text, on: codeTextField)
8181

82-
self.viewStore.producer.isLoginButtonEnabled
82+
self.viewStore.produced.isLoginButtonEnabled
8383
.assign(to: \.isEnabled, on: loginButton)
8484

85-
self.viewStore.producer.alert
85+
self.viewStore.produced.alert
8686
.startWithValues { [weak self] alert in
8787
guard let self = self else { return }
8888
guard let alert = alert else { return }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ It is also straightforward to have a UIKit controller driven off of this store.
226226

227227
// Omitted: Add subviews and set up constraints...
228228

229-
self.viewStore.producer
229+
self.viewStore.produced
230230
.map(String.init)
231231
.assign(to: \.text, on: countLabel)
232232

233-
self.viewStore.producer.numberFactAlert
233+
self.viewStore.produced.numberFactAlert
234234
.startWithValues { [weak self] numberFactAlert in
235235
let alertController = UIAlertController(
236236
title: numberFactAlert, message: nil, preferredStyle: .alert

Sources/ComposableArchitecture/ViewStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import SwiftUI
3333
/// func viewDidLoad() {
3434
/// super.viewDidLoad()
3535
///
36-
/// self.viewStore.producer.count
36+
/// self.viewStore.produced.count
3737
/// .startWithValues { [weak self] in self?.countLabel.text = $0 }
3838
/// }
3939
///
@@ -49,7 +49,7 @@ public final class ViewStore<State, Action>: ObservableObject {
4949
@available(*, deprecated, message: """
5050
Consider using `.produced` instead, this variable is added for backward compatibility and will be removed in the next major release.
5151
""")
52-
var producer: Produced<State> { produced }
52+
public var producer: StoreProducer<State> { produced }
5353

5454
/// Initializes a view store from a store.
5555
///

0 commit comments

Comments
 (0)