Commit Graph

965 Commits

Author SHA1 Message Date
Ryu
30ab89daa4 fix syntax error (#2731) 2024-01-28 10:22:09 -08:00
Stephen Celis
c373d8eae3 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 f221ed0e1a.

* 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>
2024-01-26 16:59:03 -08:00
Takuto NAKAMURA (Kyome)
4465e4eb59 Fix Composing features tutorial; Modify Make the State conform to Equatable to pass the test. (#2727)
* Make the State conform to Equatable to pass the test

* Add note about Equatable.

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-01-25 19:08:34 -08:00
hmhv
36331fcc4e fix to send action (#2726) 2024-01-25 09:17:01 -08:00
Jon Cox
d3a9465e2c Documentation: Fixed a small typo. (#2723) 2024-01-24 14:13:01 -08:00
Stephen Celis
969b5734fd Use XCTExpectFailure from XCTestDynamicOverlay (#2721)
The test store has dynamically loaded this helper for awhile now, but
now we can offload that work to another library.
2024-01-23 12:16:56 -08:00
Stephen Celis
11184dfa8c Update TestStore.swift (#2720) 2024-01-22 22:33:07 -08:00
Luke Redpath
d1eaa5d6aa Add stack action path element subscript to testing notes (#2704)
* Add stack action path element subscript to testing notes

Updates the stack navigation documentation to include information on how to test that a specific element action is received using case key paths.

Wording could maybe be improved but its a starting point.

* Update StackBasedNavigation.md

---------

Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com>
2024-01-16 14:03:42 -08:00
Shinichiro Oba
ac2e7ac1bc Fix "Composing features" tutorial (#2698)
* Fix the filename

* Add `@MainActor` and `async` for testing the feature

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-01-08 10:50:11 -08:00
Stephen Celis
ae491c9e3f Fix tutorial indentiation for diffs 2024-01-08 10:25:52 -08:00
Stephen Celis
1b1355cf1f Fix retain cycle in PresentationModifier (#2697) 2024-01-05 18:21:28 -08:00
Brandon Williams
97304efd52 Prepare dependencies a single time when creating Store. (#2695) 2024-01-05 15:21:45 -08:00
Stephen Celis
8e3ff3d927 Tutorial fixes (#2693)
Noted a few things while watching @vincent-pradeilles work his way
through it.
2024-01-04 13:39:15 -08:00
Shinichiro Oba
7dc85c9e54 Delete trailing whitespace to prevent unnecessary diffs (#2692) 2024-01-04 09:01:41 -08:00
Stephen Celis
24a1f368f8 Improve TestStore.receive(\.action, payload) failures (#2691)
This commit improves the failure messaging for the new
`TestStore.receive` method by rendering a diff of the value when the
payload doesn't match up.
2024-01-02 18:02:30 -08:00
Stephen Celis
16f428c5dc Remove state subscript key paths for coalescing optional state (#2690)
Due to a bug in Swift key paths
(https://github.com/apple/swift/issues/70611) we should use closures
when maintaining a memoized cache of optional child state.
2024-01-02 14:25:38 -08:00
Stephen Celis
1884ec55ab Fix SwiftUI warning (#2688)
I noticed this when taking SyncUps for a spin. When I was editing an
attendee and added a new one while the current attendee autocompleted,
I'd get a warning in the `ViewStore`'s `sink` where `objectWillChange`
was getting pinged during a render.

I'm pretty sure we should be dropping the first value from the `sink` to
prevent `objectWillChange` from being pinged when the `ViewStore` is
being initialized in the view.
2024-01-02 11:04:29 -08:00
mbrandonw
1aa0a951d2 Run swift-format 2023-12-22 21:05:01 +00:00
Brandon Williams
6200779372 Receive action with value checking. (#2669)
* Receive action with value checking.

* added migration guide

* wip

* improve test

* wip

* fix test
2023-12-22 15:04:11 -06:00
stephencelis
1d5ed2c4d0 Run swift-format 2023-12-22 19:56:29 +00:00
Stephen Celis
1d52033c38 Optimization: Key path subscript presentation scopes (#2680)
* Optimization: Key path subscript presentation scopes

* fix

* Fix some tests.

* another fix

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-12-22 11:42:05 -08:00
tomokisun
6ed03a729b Fix typo (#2678) 2023-12-21 17:14:51 -08:00
Brandon Williams
82917f19b2 Docs about new store scoping characteristics (#2676)
* Update migration guide for 1.5.6

* wip

* wip

* Update MigratingTo1.5.md

* Update MigratingTo1.5.md

* Update Performance.md

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-12-21 17:03:15 -06:00
Brandon Williams
aa81d7887d Fix ownership between parent and child stores (#2674)
* Fix init logging in Store.

* Avoid cycle

* invert check

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* clean up

* wip

* Update Sources/ComposableArchitecture/Store.swift

* xcode 15.1

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-12-21 17:03:01 -06:00
stephencelis
8edcd12683 Run swift-format 2023-12-20 02:36:02 +00:00
Stephen Celis
087b6b5730 Overhaul store scope communication (#2664)
* store 2

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* check sharesStorage in ==

* wip

* wip

* fix crashes

* wip

* wip

* wip

* wip

* clean up

* wip

* wip

* wip

* wip

* rename

* wip

* wip

* fix

* stack

* wip

* wip

* wip

* wip

* wip

* wip

* remove duplicates based on presentation storage

* wip

* wip

* wip

* wip

* update log snapshots

* bring back expected failure

* wip

* remove removeDuplicates

* test for fast path of PresentationState

* wip

* Updated logs

* wip

* wip

* wip

* wip

* Skip flakey CI test

* bump timeout

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-12-19 18:35:08 -08:00
Brandon Williams
b091bd72fd Basics of composition in the "essentials" tutorial (#2659)
* New tutorial section for composing features.

* wip

* wip

* wip

* wip

* wip

* wip

* fix

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-12-19 16:48:44 -06:00
Stephen Celis
6f1e0237c8 Migration guide: @CasePathable tweaks (#2672)
* Migration guide: `@CasePathable` tweaks

Tweaks the 1.4 migration guide a bit to note that `@CasePathable` is
explicitly needed in some cases.

* wip

* Update Sources/ComposableArchitecture/Documentation.docc/Articles/MigratingTo1.4.md

* Update Sources/ComposableArchitecture/Documentation.docc/Articles/MigratingTo1.4.md

---------

Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com>
2023-12-19 14:42:20 -08:00
Stephen Celis
4cdf670a21 Refactor rescoping for non-optional action sending (#2654)
Store rescoping optionalizes the action embedding in order to
short-circuit actions sent from invalid bindings, but we can push that
bit of logic into the reducer itself.
2023-12-13 14:45:16 -08:00
Stephen Celis
cb9c1f845b Revert "Fix Store leak when async effect is in flight (#2643)" (#2648)
* wip

* wip
2023-12-12 14:07:02 -08:00
Stephen Celis
b86012c82d Fix Store leak when async effect is in flight (#2643)
* Fix Store leak when async effect is in flight

A [Slack
conversation](https://pointfreecommunity.slack.com/archives/C04KQQ7NXHV/p1702049135565039)
pointed to a potential leak of the `Store` when it was executing an
effect. This PR allows cancellation to properly propagate during
deinitialization, and ensures that async effects don't strongly capture
the store.

* wip

* feedback

* wip
2023-12-11 21:32:49 -08:00
Rhys Morgan
c6b0a6c437 Fix archiving problem since 1.4.0 (#2641)
* Fix BindingReducer.swift

After discussion with Jon Shier (@jshier) on the Slack, he suggested making this change.
It appears to fix the key path getter error that was appearing when trying to archive a project using the BindingReducer.
I've tested a project which compiled but failed to archive on TCA 1.4 onwards, when macros were introduced, and this change allows it to compile and archive successfully.

* Update Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift

---------

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2023-12-11 16:58:44 -08:00
Stephen Celis
88d995db25 Fix tutorial diffs (#2642)
While tutorials appear to compile just fine when files are referenced as
strings and omitting the file suffix, it mysteriously breaks the diffing
between each step. This PR fixes things.
2023-12-11 14:40:18 -08:00
Brandon Williams
d3db821508 Improve docs for sharing logic in parent and child features. (#2638)
* Improve docs for sharing logic in parent and child features.

* wip

* wip

* wip

* Update Sources/ComposableArchitecture/Documentation.docc/Articles/Performance.md

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-12-11 16:38:26 -06:00
Brandon Williams
188ecd18d2 Don't replay changes to invalidated child stores. (#2633)
* Don't replay changes to invalidated child stores.

* wip

* backport fix from observation-beta

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-12-08 09:11:15 -08:00
stephencelis
322e888029 Run swift-format 2023-12-07 20:53:07 +00:00
Stephen Celis
c2a27dcaad Child store caching improvements (#2627)
* Use `ScopeID` for all cached child stores

* wip

* wip

* wip

* wip

* wip

* wip
2023-12-07 12:39:37 -08:00
Brandon Williams
9a7d5da39b Update migration guide 1.5 (#2615)
* Update 1.5 migration guide to include info about IdentifiedAction.

* wip
2023-12-05 14:05:24 -05:00
stephencelis
dcde72151d Run swift-format 2023-12-02 16:24:30 +00:00
Stephen Celis
cf0f2f21b6 Short-circuit the store cache from uncached stores (#2605)
* wip

* wip

* Update Sources/ComposableArchitecture/Store.swift
2023-12-02 08:24:55 -08:00
Stephen Celis
f19af6ca5b Update docs to use case key paths 2023-12-01 18:31:21 -08:00
Stephen Celis
1590846afc Fix tutorial 2023-12-01 18:26:59 -08:00
Yoshinori Imajo
b65b82b2ed Fix typo. (#2606) 2023-12-01 15:30:28 -08:00
Stephen Celis
c64b6845bd Revert "Return "invalid" stores from scoping (#2601)"
This reverts commit ff276875c4.

This introduced a regression in our examples, so we should revisit in a
new PR with more test coverage.
2023-11-29 15:47:20 -08:00
Stephen Celis
ff276875c4 Return "invalid" stores from scoping (#2601)
* Return "invalid" stores from scoping

Scoping can sometimes be invalid, _e.g._ SwiftUI may scope through an
index of a collection that no longer exists while diffing in a
`ForEach`, which can cause a crash when the child state is eagerly
evaluated. This commit introduces the idea of an invalid store that will
only crash if the store's state is interacted with, avoiding crashes
that could happen deeper in SwiftUI.

* wip
2023-11-29 11:51:53 -08:00
Stephen Celis
efba1336af Fix BindingAction's case key path for extraction (#2600) 2023-11-29 11:50:46 -08:00
Brandon Williams
6772c9db2c Use @ObservedObject instead of @StateObject in NavigationStackStore. (#2599) 2023-11-29 14:26:16 -05:00
Ryu
8d92762a22 Fix typo in MigratingTo1.5.md (#2595) 2023-11-26 22:10:41 -08:00
stephencelis
3f80eb9ed0 Run swift-format 2023-11-26 19:58:23 +00:00
Thomas Grapperon
2adca50ac5 Depend on and export DependenciesMacros (#2586)
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-11-26 11:54:27 -08:00