Repository navigation
Releases
Releases · kylehughes/swift-derived-keys
v1.0.0
DerivedKeys builds cache keys from the values a Swift computation depends on, then reuses matching results.
- Cache UIKit measurements with
SizeCacheinDerivedKeysUI. Declare the properties that affect sizing, compose child caches to reuse an entire layout's size, and share results across equivalent view instances. - Bind other calculations to key paths with
ResultCacheinDerivedKeysorMainActorResultCacheinDerivedKeysUI. The result-cache guide shows how to pass a rendered line count into a separate height cache, with text measurement and layout policy kept in application code. - Use the generic core for full-value keys, projections, dependency graphs, and bounded LRU memoization.
DerivedKeysUIalso provides explicit fitting proposals andLayoutCachefor results such as an overall size and child frames.
Requirements:
- Swift tools 6.4 and Swift 6 language mode
- iOS 16.0+ or macOS 13.0+
- UIKit for UIKit-specific APIs
Add the package with Swift Package Manager:
.package(url: "https://github.com/kylehughes/swift-derived-keys", from: "1.0.0")See the README, cache contract, and result-cache guide for examples, ownership, and dependency rules.