Commit Graph

1582 Commits

Author SHA1 Message Date
mbrandonw
8624a8e2c3 Run swift-format 1.10.0 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
Yuya Mimura
6239ed01e3 Updated swift-custom-dump to latest version (#3008) 2024-04-24 16:21:04 -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
mbrandonw
e0958d3d8c Run swift-format 2024-04-22 17:28:32 +00:00
Brandon Williams
6ed45e83f0 Fix test. 2024-04-22 10:27:30 -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
David Furman
3104c9ba19 Update README.md (#2998) 2024-04-18 15:11:25 -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>
1.9.3
2024-04-17 15:31:31 -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
7e90901bac Make Effect.publisher eager (#2968)
* Make Effect.publisher eager.

* wip
2024-04-08 19:43:49 -07:00
Brandon Williams
3c1b72ff7c Small tweak to sync up logic. 2024-04-05 14:29:00 -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
mbrandonw
4254c84334 Run swift-format 2024-04-01 18:51:53 +00:00
Sam Rayner
4514a164f9 Add package access modifier support to @Reducer on enums (#2939) 2024-04-01 11:50:44 -07: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
Takehiro Kaneko
2722a3466b Fix StackBasedNavigation.md (#2944) 2024-03-25 11:10:36 -07:00
Stephen Celis
aa4115145b Enum reducers: generate Never actions for non-features (#2943)
This adjusts the `@Reducer` macro to expand extra `case feature(Never)`
for actions that aren't TCA features.

This allows folks to scope down to stores of non-features for sheets,
etc.:

```swift
.sheet(
  item: $store.scope(state: \.meeting, action: \.meeting)
) { meetingStore in
  // Must use 'Store.withState' here for non-observed feature.
  MeetingView(meeting: meetingStore.withState(\.meeting))
}
```
2024-03-25 11:16:22 +09:00
Brandon Williams
49dae77fc8 Added a test for nested dismissal. 2024-03-20 10:10:41 -07:00
Stephen Celis
0c22607ba4 Swift bug workaround for TestStore completion (#2923)
* Swift bug workaround for `TestStore` completion

* fix
2024-03-18 13:18:46 -07:00
Stephen Celis
5ab136f5dc Test store tutorial/documentation fixes (#2912)
* Test store tutorial/documentation fixes

* wip
2024-03-11 19:03:17 -07:00
stephencelis
e34b65e6e9 Run swift-format 2024-03-12 01:28:50 +00: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
LR.Snow
c90604418c fix (#2808)
'init(initialState:reducer:withDependencies:file:line:)' is deprecated: State must be equatable to perform assertions.
2024-03-11 14:51:26 -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
Luke Redpath
8907f4f8c3 fix: Give internal store an id. (#2908) 2024-03-11 11:53:13 -07:00
Takehiro Kaneko
a0acf426f7 Fix typo in TreeBasedNavigation.md (#2898) 2024-03-07 11:11:07 -08:00
Brandon Williams
115fe5af41 Update SwiftSyntax. (#2884)
* Update SwiftSyntax.

* wip

* fix

* wip

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
1.9.2
2024-03-04 22:18:31 -08:00
Stephen Celis
53af95ae3d Fix type-checking regression: remove dynamic case lookup on BindableAction (#2886) 2024-03-04 17:58:30 -08:00
Stephen Celis
9f849e748d Leverage dynamic case writability in example code (#2885)
* Support chainable writability for dynamic case lookup

* wip

* wip

* wip

* wip
2024-03-04 16:17:51 -08:00
Takehiro Kaneko
dfe8e576b7 Fixed document (#2882) 2024-03-03 09:13:06 -08:00
Jon Shier
c5cefcd28f Add Links to Migration Guides in README (#2877)
* Add migration guide link.

* Put direct links in documentation section.

* Move guide links inline with docs.

* Remove index link.

* Update README.md

---------

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2024-03-01 13:00:49 -08:00
Takehiro Kaneko
687e27795a Fixed a small typo on migration guide 1.9 (#2876) 1.9.1 2024-02-29 20:41:49 -08:00
Brandon Williams
2ddf47f87b Disfavor new subscript (#2875)
* Disfavor case key path for binding actions.

* wip

* fix

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-02-29 14:25:40 -08:00
Brandon Williams
9dcbfd91bd Make enum reducer state equatable in tutorial. (#2873) 2024-02-29 14:25:31 -08:00
stephencelis
88a46fbdeb Run swift-format 1.9.0 2024-02-29 02:55:19 +00:00
Stephen Celis
59f5eec0ff Update docs/examples to leverage TestStore.send(\.path) (#2868) 2024-02-28 17:57:35 -08:00
stephencelis
b070b765e1 Run swift-format 2024-02-28 23:07:18 +00:00
George Scott
b4a3d04267 Add overloads of TestStore.send that accept CaseKeyPaths (#2681)
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2024-02-28 15:06:27 -08:00
stephencelis
3346f12001 Run swift-format 2024-02-26 21:03:34 +00:00
Stephen Celis
656fa9ce2e Support #if branching in enum reducers/state (#2800)
* Support `#if` branching in enum reducers/state

This adds support for `#if` branching across enum cases in observable
state and reducer enums.

* wip

* add tests

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-02-26 13:02:33 -08:00
Stephen Celis
591f1a48fb Fix perception warnings (#2849) 2024-02-26 12:01:59 -08:00
Stephen Celis
b8b726c27e Add Reducer.dependency(value) (#2863)
This new reducer operator can be used to directly assign a dependency
key value to the reducer's dependencies.

```swift
// Before;

@Dependency(\.apiClient) var apiClient
// ...
.dependency(\.apiClient, apiClient)

// After:

@Dependency(APIClient.self) var apiClient
// ...
.dependency(apiClient)
```
2024-02-26 12:01:47 -08:00
Stephen Celis
434c648d54 Undisfavor some Store[dynamicMember:] overloads (#2793)
Came up on Slack.

These current disfavored overloads can lead to more difficult to debug
error messages, like when trying to form a binding over bindable actions
with state that isn't equatable.
2024-02-26 12:01:35 -08:00
Brandon Williams
b832aa4d45 Add bindings section to ObservationBackport.md 2024-02-25 19:05:22 -08:00
mbrandonw
468d205894 Run swift-format 2024-02-26 02:39:52 +00:00
Brandon Williams
91aed560f7 Document gotcha with macros and previews. (#2855)
* Doucment gotcha with macros and previews.

* wip

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

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

* Update Sources/ComposableArchitecture/Documentation.docc/Articles/Reducers.md
2024-02-25 18:38:43 -08:00
Brandon Williams
3492dab5f3 Remove DEBUG in tests to get more coverage in release (#2856)
* Remove a bunch of DEBUG checks to get more test coverage in release.

* wip

* bring back some debugs

* fixes

* wip
2024-02-25 18:32:10 -08:00