Skip to content

FluidGroup/swiftui-object-edge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages