mirror of
https://github.com/yattee/yattee.git
synced 2025-11-13 13:48:48 +00:00
Resolves 130+ violations including deployment target checks, code style issues, and formatting inconsistencies. Adds SwiftLint disable comments for compiler-required availability checks while maintaining deployment target compliance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
30 lines
615 B
Swift
30 lines
615 B
Swift
import Foundation
|
|
import Siesta
|
|
|
|
final class Store<Data>: ResourceObserver, ObservableObject {
|
|
@Published private var all: Data?
|
|
|
|
var collection: Data { all ?? ([item].compactMap(\.self) as! Data) }
|
|
var item: Data? { all }
|
|
|
|
init(_ data: Data? = nil) {
|
|
if data != nil {
|
|
replace(data!)
|
|
}
|
|
}
|
|
|
|
func resourceChanged(_ resource: Resource, event _: ResourceEvent) {
|
|
if let items: Data = resource.typedContent() {
|
|
replace(items)
|
|
}
|
|
}
|
|
|
|
func replace(_ items: Data) {
|
|
all = items
|
|
}
|
|
|
|
func clear() {
|
|
all = nil
|
|
}
|
|
}
|