title: How to tell SwiftUI views to bind to nested ObservableObjects
body: <p>I have a SwiftUI view that takes in an EnvironmentObject called <code>appModel</code>. It then reads the value <code>appModel.submodel.count</code> in its <code>body</code> method. I expect this to bind my view to the property <code>count</code> on <code>submodel</code> so that it re-renders when the property updates, but this does not seem to happen.</p>
  
  <p>Is this a bug? And if not, what is the idiomatic way to have views bind to nested properties of environment objects in SwiftUI?</p>
  
  <p>Specifically, my model looks like this...</p>
  
  <pre><code>class Submodel: ObservableObject {
    @Published var count = 0
  }
  
  class AppModel: ObservableObject {
    @Published var submodel: Submodel = Submodel()
  }
  </code></pre>
  
  <p>And my view looks like this...</p>
  
  <pre><code>struct ContentView: View {
    @EnvironmentObject var appModel: AppModel
  
    var body: some View {
      Text("Count: \(appModel.submodel.count)")
        .onTapGesture {
          self.appModel.submodel.count += 1
        }
    }
  }
  </code></pre>
  
  <p>When I run the app and click on the label, the <code>count</code> property does increase but the label does not update.</p>
  
  <p>I can fix this by passing in <code>appModel.submodel</code> as a property to <code>ContentView</code>, but I'd like to avoid doing so if possible.</p>