swiftui-object-edge

1.0.0

Yet another @SwiftUI.State but using autoclosure
FluidGroup/swiftui-object-edge

What's New

2025-02-02T16:36:25Z

ObjectEdge

It holds an object alongslide the view lifecycle. One of the use cases is to hold a model object in a view.

@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

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed May 14 2025 03:19:53 GMT-0900 (Hawaii-Aleutian Daylight Time)