-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration guide for 1.16. (#3491)
* Add migration guide for 1.16. * Update README.md --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com>
- Loading branch information
1 parent
333bc82
commit 69011b6
Showing
36 changed files
with
295 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ableArchitecture/Documentation.docc/Articles/MigrationGuides/MigratingTo1.16.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Migrating to 1.16 | ||
|
||
The `.appStorage` strategy used with `@Shared` now uses key-value observing instead of | ||
`NotificationCenter` when possible. Learn how this may affect your code. | ||
|
||
## Overview | ||
|
||
There are no steps needed to migrate to 1.16 of the Composable Architecture, but there has been | ||
a change to the underlying behavior of `.appStorage` that one should be aware of. When using | ||
`.appStorage` with `@Shared`, if your key does not contain the characters "." or "@", then changes | ||
to that key in `UserDefaults` will be observed using key-value observing (KVO). | ||
Otherwise, `NotificationCenter` will be used to observe changes. | ||
|
||
KVO is a far more efficient way of observing changes to `UserDefaults` and it works cross-process, | ||
such as from widgets and app extensions. However, KVO does not work when the keys contain "." | ||
or "@", and so in those cases we must use the cruder tool of `NotificationCenter`. That is not | ||
as efficient, and it forces us to perform a thread-hop when the notification is posted before | ||
we can update the `@Shared` value. For this reason it is not possible to animate changes that are | ||
made directly to `UserDefaults`: | ||
|
||
```swift | ||
withAnimation { | ||
// ⚠️ This will not animate any SwiftUI views using '@Shared(.appStorage("co.pointfree.count"))' | ||
UserDefaults.standard.set(0, forKey: "co.pointfree.count") | ||
} | ||
``` | ||
|
||
In general, we recommend using other delimeters for your keys, such as "/", ":", "-", etc.: | ||
|
||
```swift | ||
@Shared(.appStorage("co:pointfree:count")) var count = 0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Sources/ComposableArchitecture/Documentation.docc/Extensions/ReducerForEach.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.