Commit Graph

965 Commits

Author SHA1 Message Date
Brandon Williams
1c133ced26 Add important note about delegate actions. (#3135) 2024-06-04 08:37:21 -05:00
Brandon Williams
7cbde3b07f FAQ cleanup. 2024-06-03 21:52:15 -05:00
Brandon Williams
d2d79f37cf FAQ (#3138)
* Misconceptions

* wip

* wip

* wip

* Update FAQ.md

* Update FAQ.md

* wip

* Update FAQ.md

* wip

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-06-03 21:15:40 -05:00
woxtu
fb5159e888 Add syntax highlighting (#3123) 2024-05-30 08:07:53 -06:00
woxtu
146aa87f60 Fix typos (#3119) 2024-05-28 07:47:30 -07:00
btr-better
7d54fdbc5e Fixed typos in the Building SyncUps tutorial (#3107)
Co-authored-by: B Tirumala Rao <btr@betterapps.studio>
2024-05-27 09:28:15 -07:00
아리
44a8f96276 chore: typo correction (#3110) 2024-05-23 07:56:58 -07:00
Tatsuyuki Kobayashi
8a40e932cf Fix BuildingSyncUps tutorial (#3099)
* Fix 05-PersistingSyncUps

* Fix 07-SyncUpDetailNavigation

* Fix 08-RecordMeeting
2024-05-18 07:43:13 -07:00
hmhv
9664c75816 fix TestingSyncUpForm.tutorial (#3091)
* fix TestingSyncUpForm.tutorial

* revert
2024-05-17 18:36:39 -07:00
Schultz Alexis
bac0d10c7c Add @_SPI(Internal) to some of navigation apis (#3097) 2024-05-17 10:44:28 -07:00
Paweł Wszeborowski
452155f129 Fix exception when using AppStorageKey with URL Value (#3098) 2024-05-16 15:00:32 -07:00
Joseph Kokenge
3a7766468c Fix ReducerCaseEphemeral Usage Documentation (#3092) 2024-05-15 17:12:38 -07:00
Stephen Celis
e37353ec33 Add ifLet SwiftUI integration warning (#3089)
* Add `ifLet` SwiftUI integration warning

We recently added a warning when we detect that `forEach` wasn't
integrated with a reducer when path elements are pushed or popped from
the stack, and I realized that we could do similarly for `ifLet` during
dismissal.

* docc
2024-05-14 16:29:47 -07:00
Stephen Celis
57526d83aa Add ViewStore.binding migration examples to guide (#3087)
* Add `ViewStore.binding` migration examples to guide

The 1.7 guide doesn't have examples of more complex bindings, so let's
add one.

* fix

* wip

* fix
2024-05-14 10:57:03 -07:00
mbrandonw
a7daa9fb90 Run swift-format 2024-05-14 16:38:40 +00:00
Brandon Williams
0385ac4eb9 Fix a bunch of references. (#3085) 2024-05-14 09:37:45 -07:00
Brandon Williams
dd145a13c5 Fix focus in tutorial (#3072)
* Fix focus logic in tutorial.

* wip

* wip

* wip

* wip

* remove extra alert enum

* wip
2024-05-13 14:07:39 -07:00
Martin Moizard
48b57d4502 SyncUps: typos fixes (#3078) 2024-05-13 09:45:52 -07:00
Brandon Williams
1001325640 Clarify that tagged is not assumed in the tutorial. (#3076) 2024-05-13 08:54:02 -07:00
Brandon Williams
433a23118f Fix for throttle logic. (#3075) 2024-05-11 14:57:32 -07:00
seanmrich
f248eff583 Shared initializers modified to lazy load the initial value (#3060)
Co-authored-by: Sean <sean@snowfort.software>
2024-05-09 14:17:28 -07:00
Won Heo (Woody)
179240217d Enable customDump only in debug mode (#3058)
* Enable customDump only in debug mode

* Change customDump to customDumping String init
2024-05-09 13:24:50 -07:00
Brandon Williams
307c851709 New tutorial: Building SyncUps. (#3039)
* New tutorial: Building SyncUps.

* fix

* clean up

* wip

* wip

* wip

* wip

* wip

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-05-08 11:15:50 -07:00
seanmrich
4c36b18568 Make PersistenceKeyDefault load its default value lazily (#3057)
* Added autoclosure around default value for `PersistenceKeyDefault`

* Added autoclosure around default value for `PersistenceKeyDefault`

---------

Co-authored-by: Sean <sean@snowfort.software>
2024-05-08 11:15:14 -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
eda999e483 Have store.finish() assert no received actions (#3054)
* Have `store.finish()` assert no received actions

`store.finish()` should do much of the same work as `store.deinit`, but
asynchronously with a timeout. This PR updates things so that folks with
long-living test stores (_e.g._ held onto by the test case) have the
ability to assert that there are no unreceived actions.

* test

* Add docs about long-living stores
2024-05-07 12:16:07 -07:00
Stephen Celis
c0a694451f Add a note about nested enum reducers in docs (#3050)
* Add a note about nested enum reducers in docs

* wip
2024-05-06 13:02:51 -07:00
stephencelis
5cb7526485 Run swift-format 2024-05-06 19:23:41 +00:00
Stephen Celis
c76914ee09 Runtime warn when stack integration is missing from store's reducer (#3048)
* Runtime warn when reducer is missing stack integration

If SwiftUI writes to a binding and the state is invalid (it is not
inserting or removing elements from the stack), then the most likely
cause is a missing `forEach` in the reducer (or a missing integration in
some parent reducer).

This commit adds a runtime warning to detect this issue.

* wip
2024-05-06 12:18:36 -07:00
Brandon Williams
096c5546ac Propagate dependencies to reducer all the time. (#3049) 2024-05-06 11:44:06 -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
Stephen Celis
402346e297 Add @CasePathable @dynamicMemberLookup to 1.4 migration guide (#3043)
* Add `@CasePathable @dynamicMemberLookup` to 1.4 migration guide

This came up recently and I was hoping to point to a part of the
migration guide that explained it, but it didn't exist.

* wip

* wip
2024-05-02 14:51:01 -07:00
Stephen Celis
e6c0959044 Revert perception availability changes (#3036) 2024-04-30 11:43:39 -07:00
Stephen Celis
b5f3786d23 Don't warn when dismissing two layers of tree nav (#3037)
Currently, popping two layers in a nav tree will cause intermediate,
invalid stores to send `dismiss` actions when they shouldn't. This
branch avoids this by checking the store's validity before sending the
action along.

Fixes #3031.
2024-04-30 11:31:33 -07:00
Brandon Williams
9de16b3e96 Fix @Shared initializer with default nil. (#3035)
* Fix @Shared initializer with default nil.

* wip
2024-04-30 11:03:50 -07:00
larryonoff
57cfcb6b92 Fix type in Reducers.md (#3034) 2024-04-30 09:25:24 -07:00
Stephen Celis
aec373a6cc Bump Perception availability (#3025)
* Bump Perception availability

An upstream fix to Perception needs to be applied here.

* Update ObservationStateRegistrar.swift
2024-04-29 13:12:03 -07:00
Brandon Williams
8191e361ec Emit test failure when warning in release. (#3024)
* Emit test failure when warning in release.

* wip
2024-04-29 12:44:29 -07:00
Daniel Lyons
7e22846c8f Add missing NSPrivacyCollectedDataTypes to PrivacyInfo.xcprivacy (#3027)
* Add missing NSPrivacyCollectedDataTypes to PrivacyInfo.xcprivacy

* Update Sources/ComposableArchitecture/Resources/PrivacyInfo.xcprivacy

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

---------

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2024-04-29 12:35:22 -07:00
Stephen Celis
ca0a0a920a Remove Reducer._Body workaround (#3023)
* Remove `Reducer._Body` workaround

This type was mainly introduced to improve Xcode autocomplete of the
`body` property, but since the `@Reducer` macro we don't really get any
autocomplete anyway...

* wip

* fix
2024-04-29 12:06:53 -07:00
Stephen Celis
fb532be3de Organize DocC (#3022) 2024-04-29 09:46:46 -07:00
Brandon Williams
48a43b1b3c Improve docs for 'Navigating to non-reducer features' 2024-04-29 09:13:34 -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
Rhys Morgan
5c1d9b7137 Remove @unchecked from StackState's Sendable conformance (#2997)
* Updates Swift Collections to 1.1.0, and removes @unchecked from StackState's Sendable conformance

* Update Package.swift

---------

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2024-04-23 10:26:19 -07:00
David Furman
83b2c1b4c9 Tutorial fixes and updates (#3003)
* Find-and-replace: Add `@testable import CounterApp`

* Typo Fix: "you" -> "your"

* Typo fix: It's -> its

* Typo: `CounterFeature` -> `ContactsFeature`

* Find-and-replace: Switch from deprecated `.navigationBarTitle()` to `navigationTitle()`

* Typo: `using` -> `uses`

* Add `@testable import CounterApp` to the Composing Feature section

* Typo: `closet` -> `closest`

* Remove mention of now-unused forward slash syntax for case paths
2024-04-19 16:52:54 -07:00
Stephen Celis
899a68ce3c Runtime warn for nested observe calls (#2996)
* Runtime warning when we detect nested observe.

* finesse

* wip

* add some tests

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-04-17 15:31:31 -07:00
Brandon Williams
7e90901bac Make Effect.publisher eager (#2968)
* Make Effect.publisher eager.

* wip
2024-04-08 19:43:49 -07:00
Brandon Williams
67f23771ac Improve docs for stack-based navigation (#2967)
* Improve docs for stack based navigation.

* wip

* Improve docs for stack based navigation

* wip

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

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

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-04-05 12:41:32 -07:00
Takehiro Kaneko
2722a3466b Fix StackBasedNavigation.md (#2944) 2024-03-25 11:10:36 -07:00