Skip to content

SwiftStash v0.2.0

Latest

Choose a tag to compare

@tklocek tklocek released this 04 Oct 15:22
Immutable release. Only release title and notes can be modified.
40ee7ae

SwiftStash v0.2.0 lets you choose and inject the store, declare a key's default once, and persist properties of @Observable models.

There are no breaking changes to the public API and no persisted-data migration: values written by 0.1.0 read as before.

Highlights

  • StashKey<Value>: a key that carries its type and default. @Stash(.launchCount) var launchCount: Int in a model and @Stashed(.launchCount) in a view read the same default.
  • StashContainer: a class states its store once (let stashStore: StashStore), and every @Stash property follows it, so tests inject a suite without passing it to each property.
  • StashObservable (iOS 17 / macOS 14): @ObservationIgnored @Stash(…) properties of an @Observable class take part in observation. There is no mirror and no restore at launch, and writes from elsewhere update the model's observers.
  • .stashStore(_:): a hosted @Stashed takes its store from the SwiftUI environment, the counterpart of .defaultAppStorage(_:).
  • Store configuration: an instance-based SwiftStash.configureUserDefaults(_:), package-level StashScopes, and APIs to read and reset the configuration, all on one documented resolution chain.

Changes and fixes

  • Operation logs go to the unified log's .debug level, so reads and writes no longer fill the stored log. Errors stay at .error.
  • @Stashed reads back the stored value right after a write.

See CHANGELOG.md for the full list.