Commit Graph

402 Commits

Author SHA1 Message Date
Stephen Celis
ff1a875668 Bump Sharing requirement to include 2.0.0 (#3546)
* Bump Sharing requirement to include 2.0.0

* Add migration guide

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
2025-01-07 09:23:11 -08:00
Stephen Celis
42192d4574 Don't report unasserted shared changes in Reducer._printChanges() (#3528)
* Don't report unasserted shared changes in `Reducer._printChanges()`

* fix

* wip

* wip

* wip
2025-01-07 09:20:31 -08:00
mbrandonw
d602618c62 Run swift-format 2024-12-03 19:10:34 +00:00
Luke Y. W.
f6ae75760b Fix the infinite loop issue when WebSocket returns an error message in the example case. (#3508)
* fix infinite loop issue when WebSocket receives an error message

* catch the error

* syntax update
2024-12-03 13:09:10 -06:00
Stephen Celis
547d19c9dc Add Sharing dependency (#3517)
* wip

* wip

* remove old case study for shared notifications

* wip

* wip

* wip

* wip

* wip

* 1.17 migration guide

* basics migration guide

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-12-03 13:08:02 -06:00
mbrandonw
15a2accc28 Run swift-format 2024-10-09 17:46:30 +00:00
Brandon Williams
bc47c51ee6 Run sync ups tests with main serial executor (#3431)
* wip

* wip
2024-10-09 13:09:57 -04:00
Stephen Celis
f9f3e3a4cb Use AnyHashableSendable from Concurrency Extras (#3428)
* Use `AnyHashableSendable` from Concurrency Extras

Rather than use an ad hoc implementation with an `AnyHashable` under the
hood that may not be concurrency safe, let's adopt the helper we added
to the Concurrency Extras packages.

* fix

* wip

* wip
2024-10-08 13:08:38 -07:00
Stephen Celis
85417e000e Update documentation and examples to use Swift Testing (#3413)
* Testing: Case Studies

* Testing: Search

* Testing: Speech Recognition

* Testing: SyncUps

* Project Settings

* Testing: TicTacToe

* Testing: Todos

* Testing: Voice Memos

* Update tutorials/docs

* fix

* Fixes

* wip

* Update ci.yml

* Update ci.yml

* Update ci.yml

* wip

* wip

* Quiet

* fix

* wip

* wip

* flaky

* wip

* wip

* fix
2024-10-02 16:28:33 -07:00
stephencelis
4c0866420f Run swift-format 2024-09-18 21:39:29 +00:00
Brandon Williams
52258dc115 Update case studies to run in Swift 6 mode. (#3394) 2024-09-18 14:38:18 -07:00
Stephen Celis
f1af33763e Swift 6 updates (#3379)
* Swift 6 updates

  - Soft-deprecate `_SynthesizedConformance` now that Xcode 16 has fixed
    this bug.
    - Update docs accordingly.

  - Document Xcode 16 macro gotcha around custom build configuration
    names.

* wip
2024-09-12 14:11:05 -07:00
stephencelis
e0367371e6 Run swift-format 2024-09-10 15:20:01 +00:00
Mason Kim
71cfb1ef2d Existential any to protocol for Swift 6 (#3370)
* Apply existential any to protocol for Swift 6

* Update Package@swift-6.0.swift

* Update Package.swift

* Apply any to Macro.Type

* Apply any for the rest

* Applying the any keyword internally for typealias in a _KeyPath

* Undoing accidental syntax

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2024-09-10 08:01:24 -07:00
Brandon Williams
7c6fb26700 Address @Shared sendability. (#3329)
* Address @Shared sendability.

* Undo UncheckedSendable<UserDefaults>.

* clean up

* wip

* drop AnySendable.

* wip

* Address `Effect.throttle` sendability (#3325)

* Address effect cancellation sendability (#3326)

* Address effect cancellation sendability

* fix

* wip

* wip

* Separate SendableDefaultSubscript from DefaultSubscript.

* fix test

* drop escaping

* switch on swift 6 language mode

* xcode 16

* update test

* wip

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-09-06 16:28:23 -04:00
stephencelis
a619c3fe60 Run swift-format 2024-09-05 01:39:30 +00:00
MaraMincho
80aac23cf5 Edit 04-Navigation-Lists-NavigateAndLoad file in SwiftUI CaseStudies (#3327)
* Edit 04-Navigation-Lists-NavigateAndLoad file in SwiftUI CaseStudies

* Update Examples/CaseStudies/SwiftUICaseStudies/04-Navigation-Lists-NavigateAndLoad.swift

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>

* change selection Type to `Identified<Row.ID, Counter.State?>?`

---------

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-09-04 18:37:51 -07:00
mbrandonw
e4371a552e Run swift-format 2024-09-04 19:19:54 +00:00
Mason Kim
5267e5b778 Update 05-HigherOrderReducers CaseStudies (#3342)
* Update 05-HigherOrderReducers CaseStudies

* Replace alert(store:) to alert(_:)

* View clean up.

* Fixed alert.

* Update DownloadComponent.swift

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2024-09-04 15:18:58 -04:00
stephencelis
f02d8f6650 Run swift-format 2024-08-29 21:09:34 +00:00
Stephen Celis
a7e2e73f83 Swift 6: Key path sendability (#3282)
* `@preconcurrency @MainActor` isolation of `Store`

* Remove unneeded `@MainActor`s

* Remove thread checking code

* Remove unneeded `@MainActor`s

* Swift 5.10 compatibility fixes

* wip

* More 5.10 fixes

* wip

* fixes

* wip

* wip

* up the timeout

* wip

* Fixes

* wip

* wip

* wip

* wip

* wip

* Fix binding action sendability

* Address more binding action sendability

* more bindable action sendability

* more bindable action warnings

* fix

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-08-29 13:46:39 -07:00
stephencelis
dfa29e0203 Run swift-format 2024-08-27 18:28:03 +00:00
Stephen Celis
08faf84fe3 MainActor Store Isolation (#3277)
* `@preconcurrency @MainActor` isolation of `Store`

* Remove unneeded `@MainActor`s

* Remove thread checking code

* Remove unneeded `@MainActor`s

* Swift 5.10 compatibility fixes

* wip

* More 5.10 fixes

* wip

* fixes

* wip

* wip

* up the timeout

* wip

* Fixes

* Remove mainActorASAP in favor of mainActorNow. (#3288)

* wip

* Run swift-format

* Update README.md

* Fix integration tests. (#3294)

* Fix integration tests.

* wip

* wip

* Run swift-format

* mainActorNow doesnt need escaping closure

* wip

* migration guide

* wip

* Update MigratingTo1.14.md

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com>
Co-authored-by: mbrandonw <mbrandonw@users.noreply.github.com>
2024-08-27 10:57:46 -07:00
Stephen Celis
f02fab5000 Allow an alert to present another alert (#3309)
* Allow an alert to present another alert

When we added support for vanilla SwiftUI modifiers, we lost the ability
to present one alert after another because `nil` writes to the alert
bindings unconditionally dismissed the feature, even if the feature was
freshly presented.

This fixes things by suppressing dismissal when the identity of a
presented item has changed.

Fix #3272.

* wip
2024-08-26 15:19:08 -07:00
mbrandonw
0c31f223b5 Run swift-format 2024-08-20 18:28:42 +00:00
Brandon Williams
361d2d7763 Fix integration tests. (#3294)
* Fix integration tests.

* wip

* wip
2024-08-20 12:52:05 -05:00
mbrandonw
27adbdc1e6 Run swift-format 2024-08-13 20:16:24 +00:00
Stephen Celis
dae1b9aafb Leverage UIKitNavigation (#3180)
* wip

* wip

* wip

* Update

* Remove duplicate UIAlertAction convenience initializers (#3188)

* wip

* wip

* wip

* fixes

* wip

* Add nav stack helper

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* watch fix

---------

Co-authored-by: Cosmic Flamingo <67525430+acosmicflamingo@users.noreply.github.com>
Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-08-13 16:01:24 -04:00
Stephen Celis
e1f07facd9 Fix some warnings (#3279)
We have a few warnings, mostly in the test suite, that have cropped up
with deprecations and Xcode 16 strict concurrency, so let's address
them.
2024-08-12 08:24:30 -07:00
Stephen Celis
3e830b575a Swift Testing support (#3229)
* wip

* wip

* Update Testing.md

* wip

* wip

* wip

* wip

* wip:

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* disable library evolution

* bump

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-07-22 17:52:04 -07:00
aladdin
a792049575 Hide UIViewController method/properties in UIKit Example code (#3238)
* refactor: hide decrementButtonTapped function

* refactor: hide incrementButtonTapped function

* refactor: hide CounterViewController's store

* refactor: hide CountersTableViewController's store

* refactor: hide EagerNavigationViewController's store

* refactor: hide LazyNavigationViewController's store

* refactor: hide IfLetStoreController's stored properties
2024-07-14 12:00:38 -04:00
Takehiro Kaneko
10e5506e99 Improve UIKit case studies: ListsOfState (#3220) 2024-07-12 14:58:21 -07:00
aladdin
4880ed6a7c Add final to UIViewControllers in UIKit CaseStudies (#3221)
* refactor: add final to EagerNavigationViewController

* refactor: add final to LazyNavigationViewController
2024-07-02 13:57:20 -04:00
Brandon Williams
476050cba2 Convert all ActorIsolated to LockIsolated. (#3198) 2024-06-21 15:18:47 -04:00
Stephen Celis
bc8f27b1d0 Swift Language Support: Drop <5.9 (#3185)
* Swift Language Support: Drop <5.9

* wip

* wip

* wip

* wip

* wip
2024-06-19 07:40:15 -07:00
Stephen Celis
7ac630fe4c Support swift-syntax from 600.0.0-latest (#3160)
* Support swift-syntax from 600.0.0-latest

The Xcode 16 beta generates macro projects using these swift-syntax
snapshots. Luckily things seem to be backwards compatible, so we can
expand our supported range.

* wip
2024-06-12 16:02:02 -07:00
Brandon Williams
1eeca17b21 Make Shared.wrappedValue setter unavailable from async and introduce Shared.withLock (#3136)
* Add withValue to Shared, deprecate direct mutation.

* updates

* wip

* wip

* wip

* wip

* Available noasync

* withLock

* clean up

* wip

* wip

* Update SyncUpsListTests.swift

* wip

* wip

* wip

* wip

* wip

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-06-06 15:16:34 -07:00
Stephen Celis
c0d10e2366 Precondition: persistence keys must match value (#3051)
* Precondition: persistence keys must match value

We currently soft-fail if a persistence key is reused across different
types. At runtime a persistence key will write over the other's value,
and vice versa, and data is lost.

Reusing the same file storage URL or app storage key with conflicting
types is a programmer error and ideally should crash over data
corruption.

* wip

* wip
2024-05-07 12:46:22 -07:00
Stephen Celis
5d73967c3e Cancel TestStore effects when root feature is dismissed (#3044)
* Cancel `TestStore` effects when root feature is dismissed

Right now, if a leaf feature is tested and it dismisses itself while
effects are in-flight, the only way to get tests passing is to
explicitly tell the store or any tasks returned by `store.send` to
cancel. Further, you must use an expectation in such tests to assert
that `dismiss` was called in the first place.

This PR changes this behavior to automatically cancel a test store's
effects if it is dismissed, and it prohibits sending more actions to it
after dismiss has been called.

* wip

* wip
2024-05-02 17:59:13 -07:00
mbrandonw
8624a8e2c3 Run swift-format 2024-04-29 00:58:12 +00:00
Stephen Celis
e121b91fb4 Shared State (#2858)
* Shared State

* fix compiler errors in 5.7

* fixes and tests

* fix

* fix

* wip

* longer sleeps

* fix test

* fix tests

* Clean up some typos in SharingState.md (#2860)

* public inits

* wip

* wip

* add test for shared state and onChange

* Case study for sandboxing shared state

* tweaks to case study

* wip

* add tests to sandboxing case study

* rename files

* wip

* simplify sync up tests

* wip

* fix

* wip

* fix $shared.publisher non-determinism and write test that currently fails but ideally would not.

* more docs and a test for autoclosure

* more docs

* wip

* update todo with persistence

* wip

* wip

* support default `nil` optionals in `@Shared`

* Introduce unavailable overload for better diagnostics

* Fix autocomplete from `@Shared(.`

* Revert "Fix autocomplete from `@Shared(.`"

This reverts commit fd1798f9f5.

* Fix defaults

* wip

* Give persistence keys a synchronous update interface (#2880)

* Don't use async sequence for persistence

* wip

* wip

* wip

* Update Sources/ComposableArchitecture/SharedState/PersistenceKey.swift

Co-authored-by: Hal Lee <hal@lee.me>

---------

Co-authored-by: Hal Lee <hal@lee.me>

* Revert sharing in Todos for now

* wip

* wip

* Pass initial shared value to strategy / register app storage (#2904)

* Pass initial shared value to strategy / register app storage

This PR modifies the `PersistenceKey` protocol so that its `load` and
`subscribe` endpoints are handed the initial value and must return a
non-optional value. By feeding this value in, we can ensure that
`.appStorage` declared in a feature is registered outside the feature.

* wip

* wip

* wip

* wip

* wip

* wip

* swift-format

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

Co-authored-by: Pyry Jahkola <pyry.jahkola@iki.fi>

* non-exhaustive fix

* wip

* remove decodable for now

* Fix app storage registration with `nil` values

* fix

* wip

* tutorial

* fixes

* lots of tutorial fixes

* more tutorial fixes

* more tutorial fixes

* more tutorial fixes

* tutorial fixes

* wip

* re-arrange test

* Remove store shared preview quarantine

* Add support for \.defaultInMemoryStorage (#2965)

* fix

* Added Privacy Manifest file (#2930)

* Added Privacy Manifest file

* Update Package@swift-5.9.swift

---------

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>

* remove warning overloads

* write default instead of register

this is more consistent with SwiftUI's property wrapper, and causes less
strangeness when multiple repeat properties have different defaults

* move privacy manifest

* wip

* wip

* EphemeralFileStorage -> InMemoryFileStorage

* documented gotcha

* add test

* Shared state beta task snaps (#2976)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>

* wip

* Use notification center instead of KVO for user defaults observation. (#2978)

* Use notification center instead of KVO for user defaults observation.

* wip

* wip

* Introduce @SharedReader (#2979)

* wip

* wip

* wip

* wip

* wip

* wip

* Introduce @SharedReader.

* wip

* wip

* sendable

* wip

* wip

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>

* Make Shared.Subscription.cancel public (#2983)

* added failing test

* Add convenience initializers

* Save to file storage when app is about to be terminated (#2992)

* Save file storage on termination too.

* wip

* Shared change tracking enhancements (#2989)

* wip

* wip

* wip

* wip

* Add unavailable conformance

* wip

* wip

* wip

* Don't need to check for previews.

* Add default providing persistence key (#2980)

* wip - default providing key

* warn on default access

* Revert "warn on default access"

This reverts commit 38706450bef44a50f94afeaddbc4628e383b52b3.

* wip

* wip

* wip - tests

* wip - reader key

* fix docs

* A few changes.

* A few more changes.

* docs

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>

* Fix optional shared defaults.

* undo last commit but keep test

* wip

* Better shared state change tracking and `TestStore` interactions (#2995)

* A fix for shared assertion.

* fixes

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>

* docs

* docs

* wip

* Throttle for 1 second.

* fix typo in examples: `let` -> `var` (#2999)

Co-authored-by: Andreas Tielmann <atielmann@deloitte.de>

* wip

* wip

* fix observing projection

* Ping `Shared.publisher` in `willSet` so prev/next values observable

* wip

* wip

* remove sandbox demo

* wip

* wip

* recover inlining

* wip

* wip

* fix docc

* wip

* wip

* re-entrant test

* wip

* Don’t assume CastableLookup (#3011)

* Don’t assume CastableLookup

If the observed value in `UserDefaults` is a `RawRepresentable` type, simply casting to `Value` might fail because the raw representing type could be different from `Value`.  Instead of querying `UserDefaults` directly here, we should call `loadValue()` which will do the right thing for raw representable types (esp. try to call `Value.init(rawValue:)` with the value obtained from `UserDefaults`).

* Add test

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>

* Make `FileStorage` more opaque (#3010)

* Make `FileStorage` more opaque

Previously, we had a public protocol and conformances, but we don't
expect anyone to conform outside the library, so instead let's hide
things in a more opaque struct.

The downside of this PR is that it's a breaking API change pretty late
in the game:

```diff
-$0.defaultFileStorage = InMemoryFileStorage()
+$0.defaultFileStorage = .inMemory
```

We could add public deprecated functions that emulate the old
initializers if we think it's worth it...

* wip

* wip

* wip

* wip

* wip

* wip

* fix for 5.7.1

* sync ups clean up

* more docs

* more tests

* shared testing tiups

* wip

* wip

* Fix typo. (#3014)

* more shared state docs

* relax version of swift-dependencies.

* dep change

* fix == and hash on Shared and more tests

* revert == changes

* add test

* Remove hashable conformance from shared

* remove conditional encodability from shared

* wip

* remove syncups tutorial

* wip

* fix

* fix file storage deletion resubscription

* wip

* wip

* wip

* wip

* wip

* fix

* eager throttle

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
Co-authored-by: NF <4764329+NFulkerson@users.noreply.github.com>
Co-authored-by: Hal Lee <hal@lee.me>
Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com>
Co-authored-by: Pyry Jahkola <pyry.jahkola@iki.fi>
Co-authored-by: Daniel Lyons <72824209+DandyLyons@users.noreply.github.com>
Co-authored-by: Hilton Campbell <github@crosswaterbridge.com>
Co-authored-by: Luke Redpath <lredpath@community.com>
Co-authored-by: andtie <andreas.tielmann@gmail.com>
Co-authored-by: Andreas Tielmann <atielmann@deloitte.de>
Co-authored-by: Alex Kovács <alex@kobachi.jp>
Co-authored-by: Zev Eisenberg <zev@zeveisenberg.com>
2024-04-28 17:53:12 -07:00
Ikko Eltociear Ashimine
ca28c7b5b8 Update 01-GettingStarted-SharedState.swift (#2994)
reseting -> resetting
2024-04-16 11:15:25 -07:00
Brandon Williams
640a72ec71 Fix dismissal in UIKit demos. (#2986)
* Fix dismissal in UIKit demos.

* Revert test code
2024-04-14 12:55:10 -07:00
Brandon Williams
3c1b72ff7c Small tweak to sync up logic. 2024-04-05 14:29:00 -07:00
mbrandonw
4254c84334 Run swift-format 2024-04-01 18:51:53 +00:00
Oleg Langer
03015060b3 Fix Favorites case study by using episode mocks (#2962)
* Fix favorites case study by using episode mocks

* Small tweaks

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-04-01 11:50:08 -07:00
Stephen Celis
c383ce6e94 Fix SwiftSyntax 510 / Xcode 15.3 warnings (#2909)
* Fix SwiftSyntax 510 / Xcode 15.3 warnings

* fix

* wip

* wip
2024-03-11 18:27:52 -07:00
Brandon Williams
ed7a36651f Change "inert" state to have an ever-changing ID (#2910)
* re-record tests before inert change

* record after inert id change

* remove _$inert
2024-03-11 14:44:57 -07:00
Daiki Matsudate
8f0b35056b Add StackActionOf (#2906)
Signed-off-by: Daiki Matsudate <d.matsudate@gmail.com>
2024-03-11 14:03:26 -07:00
Stephen Celis
53af95ae3d Fix type-checking regression: remove dynamic case lookup on BindableAction (#2886) 2024-03-04 17:58:30 -08:00