https://github.com/fluidgroup/swiftui-object-edge
Yet another @SwiftUI.State but using autoclosure
https://github.com/fluidgroup/swiftui-object-edge
Last synced: 12 months ago
JSON representation
Yet another @SwiftUI.State but using autoclosure
- Host: GitHub
- URL: https://github.com/fluidgroup/swiftui-object-edge
- Owner: FluidGroup
- License: mit
- Created: 2025-02-02T14:35:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-02T16:36:25.000Z (over 1 year ago)
- Last Synced: 2025-07-10T21:07:21.252Z (12 months ago)
- Language: Swift
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ObjectEdge
It holds an object alongslide the view lifecycle.
One of the use cases is to hold a model object in a view.
```swift
@available(iOS 17, *)
@Observable
private final class Model {
var count: Int = 0
func up() {
count += 1
}
}
@available(iOS 17, *)
private struct Demo: View {
@ObjectEdge var model: Model = .init()
var body: some View {
VStack {
Text("\(model.count)")
Button("Up") {
model.up()
}
}
}
}
```
A question about how to use model objects using `@Observable`.
https://forums.developer.apple.com/forums/thread/739163