Skip to content

Commit c373d8e

Browse files
stephencelismbrandonwhmhvJimmy-PrimeMika5652
authored
Observable Architecture (#2593)
* bring back view store performance * wip * Allow chaining of store bindings * wip * Localize ignoring bindings to text field resignation/dismissal * wip * fix DiagnosticsError message (#2597) * store collection * wip * wip * update migration guide * Add `@Presents` macro for observable presentation While it would be nice for the `@PresentationState` property wrapper to "just work" with TCA's upcoming observable tools, sadly that does not seem to be the case. Adding observation directly to `@PresentationState`, as we have done with the beta so far, can break existing projects due to the additional observation. This primarily manifests itself in projects that present navigation stacks, where the `@PresentationState` observation can cause the navigation hierarchy to recompute and trigger SwiftUI bugs. The best we've come up with so far is introducing a brand new macro that automatically wraps a property with `@PresentationState` _and_ instruments it with observation. We're open to other ideas, and we do have future plans to eliminate the need for a property wrapper or macro at all, but till then this offers a non-breaking upgrade path! * fixes * Observe child store changes * wip * wip * wip * Fix typo in MigratingTo1.6.md (#2608) * Rename bindingViewStore argument to store in MigratingTo1.6.md (#2611) * wip * Revert "wip" This reverts commit f221ed0. * Add `@Presents` macro for observable presentation (#2604) * Add `@Presents` macro for observable presentation While it would be nice for the `@PresentationState` property wrapper to "just work" with TCA's upcoming observable tools, sadly that does not seem to be the case. Adding observation directly to `@PresentationState`, as we have done with the beta so far, can break existing projects due to the additional observation. This primarily manifests itself in projects that present navigation stacks, where the `@PresentationState` observation can cause the navigation hierarchy to recompute and trigger SwiftUI bugs. The best we've come up with so far is introducing a brand new macro that automatically wraps a property with `@PresentationState` _and_ instruments it with observation. We're open to other ideas, and we do have future plans to eliminate the need for a property wrapper or macro at all, but till then this offers a non-breaking upgrade path! * wip * Fix perception bindings (#2609) * Fix runtime warning when binding accesses perceptible state. * Fix runtime warning in SwiftUI bindings. * wip * wip * wip * wip * wip * wip * wip * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com> * wip * wip * fix * wip * wip * wip * Check observable state identity for presentation state. * Add willSset/didSet to registrar types. * clean up @presents * clean up * fix * Emit observation warnings in escaping contexts like `ForEach` and `sheet` (#2613) * Fix perception warning in ForEach. * fix --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com> * Introduce @ViewAction(for:) macro. (#2612) * Add back @ViewAction macro. * wip * wip * wip * wip * wip * clean up * wip * wip * fix migration guide' * ViewActionable * wip * rename * wip * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com> * Introduce @BindableStore for bindings in pre-iOS 17 (#2610) * Introduce @BindableStore. * docs * wip * wip * fixc * wip * wip * wip * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com> * re-record intergration logs * wip * wip * localize invalid stores to store collection * Deprecate closure-based `store.scope` operations (#2618) These uncached operations can be problematic, especially when working with observation, which often depends on the stable identity of stores. * document * Update warning message * Performance Improvement: Skip perception checks when calling reducers. (#2622) * Skip perception checks when calling reducers. * inline withoutPerceptionChecking() for RELEASE Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com> --------- Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com> * Don't show perception warnings in action closures. (#2614) * Don't show perception warnings in action closures. * wip * wip * wip * clean up * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com> * fix BindableStore + release * Add docs * Change associated type names of ViewActionSending (#2629) * Fix some @ViewAction annoyances. * wip * wip * wip * wip * wip * wip * fix * wip * fixed merge * Add new view modifiers for observing alerts/dialogs (#2628) * Add new view modifiers for observing alerts/dialogs Instead of: ```swift .alert(store: store.scope(state: \.$alert, action: \.alert)) ``` You can now do: ```swift .alert($store.scope(state: \.alert, action: \.alert)) ``` This new modifier is powered by the same store binding scope operation that can power `sheet(item:)`, etc., and is much lighter weight than the previous view modifier, which spun up view stores and `WithViewStore` views. * wip * wip * wip --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com> * Fix uncached warning when using Store.ifLet (#2625) * Fix uncached warning when using Store.ifLet * wip * wip * wip * wip * wip * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com> * Resolve packages * Updated scopes * wip * wip * updated binding docs * adding docs * clean up * wip * wip * wip * clean up * clean up * clean up * wip; * lots of fixes * update more docs * fix * wip * wip * Remove ObservationRegistrarWrapper. (#2634) * Remove ObservationRegistrarWrapper. * Delete Sources/ComposableArchitecture/Internal/ObservationRegistrarWrapper.swift --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com> * more docs * update docs * a few more tests * fix * wip * wip * wip * Cache data in store collections (#2635) * fix tutorial highlighting * wip * wip * wip * wip * tests for observation of special domain types * another test * fix * wip * Implement memoization for perception checks (#2630) * Implement memoization for isInSwiftUIBody * tidy up * Perception caching updates (#2649) * Small updates to perception caching. * wip * debug * some more macro tests * syncups tutorial beginnings * wip * wip * wip * wip * wip * merge fixes * wip * update tests * fix * fix * fix perception checking in store * rename task local * delete old test * deprecate test using old apis * fix test * perception tests for store * wip * wip * wip * wip * wip * wip * wip * Opt out of key path for Store.ifLet * sync ups * lots more sync up tutorial * more sync ups tutorial * wip * wip * wio * wip * wip * wip * updated references of 1.6 to 1.7 * wip * no need to force unwrap here * fixed crash in ForEach with bindings * more sync ups tutorial * more sync ups tutorial * wip * more sync ups * wip * wip * Better support for observing copies of values (#2650) * Explore using _modify * wip * wip * wip * wip * wip * wip * more tests * wip * get another failing test for an edge case * wip * tests all passing * flag for determining when new state was created * wip * clean up * wip * wip * wip; * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * New test that currently fails. * wip * wip * Update Sources/ComposableArchitectureMacros/PresentsMacro.swift * wip * remove redundant attached member attribute * storage * cleanup * more benchmarks and tests * wip * wip * wip * wip * update tests * wip * wip --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com> * wip * wip * wip * swift-format * fix * wip * wip * wip * wip * Perception * wip * wip * clean up shared state * fix shared state tests * wip * add alert test * wip * wip * wip * wip * Use transaction in binding * wip * wip * wip * wip * wip * wip * uikit * keep references to controllers when presenting so that we can properly dismiss * change order of features in shared state demo * wip * cleanup * cleanup * wip * wip * wip * Fix perception checking for effect actions. * wip * wip * wip * Fix perception checking for effect actions. * wip * wip * remove sync ups tutorial * wip * wip * wip * wip * wip * docs for observe function for uikit * Add cancellation to observation' * re-record integration test snapshots * fixed some todos * update test * remove 5.9.2 checks * wip * improve docs * update docs * updates * lots of fixes * more docs * remove unneeded file; * wip * wip * wip * update readme and getting started * wip * simplify * migration stuff * wip * Update Models.swift * wip * wip * wip * Update Bindings.md * wip * wip * wip * wip * fix * wip * wip * wip * wip * wip Co-authored-by: Kabir Oberai <oberai.kabir@gmail.com> --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com> Co-authored-by: hmhv <admin@hmhv.info> Co-authored-by: Jimmy Prime <jimmylevelup@gmail.com> Co-authored-by: Michael Pohl <15653162+Mika5652@users.noreply.github.com> Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com> Co-authored-by: George Scott <gscott@gekkoto.com> Co-authored-by: Kabir Oberai <oberai.kabir@gmail.com>
1 parent 4465e4e commit c373d8e

File tree

357 files changed

+17188
-8116
lines changed

Some content is hidden

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

357 files changed

+17188
-8116
lines changed

.github/package.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
- release
2525
steps:
2626
- uses: actions/checkout@v4
27-
- name: Select Xcode 15.1
28-
run: sudo xcode-select -s /Applications/Xcode_15.1.app
27+
- name: Select Xcode 15.2
28+
run: sudo xcode-select -s /Applications/Xcode_15.2.app
2929
- name: Run ${{ matrix.config }} tests
3030
run: make CONFIG=${{ matrix.config }} test-library
3131

@@ -34,8 +34,8 @@ jobs:
3434
runs-on: macos-13
3535
steps:
3636
- uses: actions/checkout@v4
37-
- name: Select Xcode 15.1
38-
run: sudo xcode-select -s /Applications/Xcode_15.1.app
37+
- name: Select Xcode 15.2
38+
run: sudo xcode-select -s /Applications/Xcode_15.2.app
3939
- name: Build for library evolution
4040
run: make build-for-library-evolution
4141

@@ -59,8 +59,8 @@ jobs:
5959
runs-on: macos-13
6060
steps:
6161
- uses: actions/checkout@v4
62-
- name: Select Xcode 15.1
63-
run: sudo xcode-select -s /Applications/Xcode_15.1.app
62+
- name: Select Xcode 15.2
63+
run: sudo xcode-select -s /Applications/Xcode_15.2.app
6464
- name: Run benchmark
6565
run: make benchmark
6666

@@ -69,7 +69,7 @@ jobs:
6969
runs-on: macos-13
7070
steps:
7171
- uses: actions/checkout@v4
72-
- name: Select Xcode 15.1
73-
run: sudo xcode-select -s /Applications/Xcode_15.1.app
72+
- name: Select Xcode 15.2
73+
run: sudo xcode-select -s /Applications/Xcode_15.2.app
7474
- name: Run tests
7575
run: make test-examples

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

Examples/CaseStudies/CaseStudies.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
DC4C6EB62450DD380066A05D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC4C6EB42450DD380066A05D /* LaunchScreen.storyboard */; };
5656
DC4C6EC12450DD390066A05D /* UIKitCaseStudiesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4C6EC02450DD390066A05D /* UIKitCaseStudiesTests.swift */; };
5757
DC4C6ED62450E1050066A05D /* CounterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4C6ED52450E1050066A05D /* CounterViewController.swift */; };
58-
DC4C6ED82450E4570066A05D /* UIViewRepresented.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4C6ED72450E4570066A05D /* UIViewRepresented.swift */; };
5958
DC4C6EDA2450E6050066A05D /* NavigateAndLoad.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4C6ED92450E6050066A05D /* NavigateAndLoad.swift */; };
6059
DC5B505125C86EBC000D8DFD /* 01-GettingStarted-Bindings-Forms.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5B505025C86EBC000D8DFD /* 01-GettingStarted-Bindings-Forms.swift */; };
6160
DC630FDA2451016B00BAECBA /* ListsOfState.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC630FD92451016B00BAECBA /* ListsOfState.swift */; };
@@ -199,7 +198,6 @@
199198
DC4C6EC02450DD390066A05D /* UIKitCaseStudiesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitCaseStudiesTests.swift; sourceTree = "<group>"; };
200199
DC4C6EC22450DD390066A05D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
201200
DC4C6ED52450E1050066A05D /* CounterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CounterViewController.swift; sourceTree = "<group>"; };
202-
DC4C6ED72450E4570066A05D /* UIViewRepresented.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewRepresented.swift; sourceTree = "<group>"; };
203201
DC4C6ED92450E6050066A05D /* NavigateAndLoad.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateAndLoad.swift; sourceTree = "<group>"; };
204202
DC5B505025C86EBC000D8DFD /* 01-GettingStarted-Bindings-Forms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "01-GettingStarted-Bindings-Forms.swift"; sourceTree = "<group>"; };
205203
DC630FD92451016B00BAECBA /* ListsOfState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListsOfState.swift; sourceTree = "<group>"; };
@@ -313,7 +311,6 @@
313311
children = (
314312
DC25DC632450F2DF00082E81 /* ActivityIndicatorViewController.swift */,
315313
DC25DC5E2450F13200082E81 /* IfLetStoreController.swift */,
316-
DC4C6ED72450E4570066A05D /* UIViewRepresented.swift */,
317314
);
318315
path = Internal;
319316
sourceTree = "<group>";
@@ -706,7 +703,6 @@
706703
isa = PBXSourcesBuildPhase;
707704
buildActionMask = 2147483647;
708705
files = (
709-
DC4C6ED82450E4570066A05D /* UIViewRepresented.swift in Sources */,
710706
DC25DC642450F2DF00082E81 /* ActivityIndicatorViewController.swift in Sources */,
711707
DC4C6ED62450E1050066A05D /* CounterViewController.swift in Sources */,
712708
DC4C6EDA2450E6050066A05D /* NavigateAndLoad.swift in Sources */,
@@ -835,7 +831,6 @@
835831
SDKROOT = appletvos;
836832
SWIFT_VERSION = 5.0;
837833
TARGETED_DEVICE_FAMILY = 3;
838-
TVOS_DEPLOYMENT_TARGET = 13.3;
839834
};
840835
name = Debug;
841836
};
@@ -855,7 +850,6 @@
855850
SDKROOT = appletvos;
856851
SWIFT_VERSION = 5.0;
857852
TARGETED_DEVICE_FAMILY = 3;
858-
TVOS_DEPLOYMENT_TARGET = 13.3;
859853
};
860854
name = Release;
861855
};
@@ -877,7 +871,6 @@
877871
SWIFT_VERSION = 5.0;
878872
TARGETED_DEVICE_FAMILY = 3;
879873
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/tvOSCaseStudies.app/tvOSCaseStudies";
880-
TVOS_DEPLOYMENT_TARGET = 13.3;
881874
};
882875
name = Debug;
883876
};
@@ -899,7 +892,6 @@
899892
SWIFT_VERSION = 5.0;
900893
TARGETED_DEVICE_FAMILY = 3;
901894
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/tvOSCaseStudies.app/tvOSCaseStudies";
902-
TVOS_DEPLOYMENT_TARGET = 13.3;
903895
};
904896
name = Release;
905897
};

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

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ private let readMe = """
2323

2424
@Reducer
2525
struct AlertAndConfirmationDialog {
26+
@ObservableState
2627
struct State: Equatable {
27-
@PresentationState var alert: AlertState<Action.Alert>?
28-
@PresentationState var confirmationDialog: ConfirmationDialogState<Action.ConfirmationDialog>?
28+
@Presents var alert: AlertState<Action.Alert>?
29+
@Presents var confirmationDialog: ConfirmationDialogState<Action.ConfirmationDialog>?
2930
var count = 0
3031
}
3132

@@ -106,29 +107,23 @@ struct AlertAndConfirmationDialog {
106107
// MARK: - Feature view
107108

108109
struct AlertAndConfirmationDialogView: View {
109-
@State var store = Store(initialState: AlertAndConfirmationDialog.State()) {
110+
@Bindable var store = Store(initialState: AlertAndConfirmationDialog.State()) {
110111
AlertAndConfirmationDialog()
111112
}
112113

113114
var body: some View {
114-
WithViewStore(self.store, observe: { $0 }) { viewStore in
115-
Form {
116-
Section {
117-
AboutView(readMe: readMe)
118-
}
119-
120-
Text("Count: \(viewStore.count)")
121-
Button("Alert") { viewStore.send(.alertButtonTapped) }
122-
Button("Confirmation Dialog") { viewStore.send(.confirmationDialogButtonTapped) }
115+
Form {
116+
Section {
117+
AboutView(readMe: readMe)
123118
}
119+
120+
Text("Count: \(store.count)")
121+
Button("Alert") { store.send(.alertButtonTapped) }
122+
Button("Confirmation Dialog") { store.send(.confirmationDialogButtonTapped) }
124123
}
125124
.navigationTitle("Alerts & Dialogs")
126-
.alert(
127-
store: self.store.scope(state: \.$alert, action: \.alert)
128-
)
129-
.confirmationDialog(
130-
store: self.store.scope(state: \.$confirmationDialog, action: \.confirmationDialog)
131-
)
125+
.alert($store.scope(state: \.alert, action: \.alert))
126+
.confirmationDialog($store.scope(state: \.confirmationDialog, action: \.confirmationDialog))
132127
}
133128
}
134129

0 commit comments

Comments
 (0)