Currently the shared state is not listening for changes to the user defaults that happens externally so that it can update itself accordingly. This is the same problem we saw with holding onto @AppStorage
in an @Observable
object. It could clearly load from and save to user defaults, but it didn’t observe changes made to user defaults from other parts of the application.
But unlike that situation, we can actually fix it for our @Shared
property wrapper. We can beef up the PersistenceKey
protocol so that conformers to it are capable of describing updates to the value that happen in the external system, such as user defaults or the file system, and then the Storage
type can use that information to update its currentValue
accordingly.
Let’s see what it takes.