title: SwiftUI onTapGesture does not work with ObservedObject in Mac app
body: <p>I would like to update a view (RightView) based on actions from a tap gesture in another view (LeftView). Below is my example code to accomplish this:</p>
  
  <p><strong>AppState.swift</strong></p>
  
  <pre><code>import Foundation
  
  class AppState: ObservableObject {
      @Published var tapCount: Int = 0
  
      func incrementTapCount() {
          self.tapCount += 1
          print("tap count \(self.tapCount)")
      }
  }
  </code></pre>
  
  <p><strong>LeftView.swift</strong></p>
  
  <pre><code>import SwiftUI
  
  struct LeftView: View {
      @ObservedObject var appState = AppState()
  
      var body: some View {
          VStack {
              Text("Left View")
          }
          .frame(width: 100, height: 200)
          .onTapGesture {
              print("tapped left view")
              self.appState.incrementTapCount()
          }
      }
  }
  </code></pre>
  
  <p><strong>RightView.swift</strong></p>
  
  <pre><code>import SwiftUI
  
  struct RightView: View {
      @ObservedObject var appState = AppState()
  
      var body: some View {
          VStack {
              Text("Right View")
              Text("Tap Count: \(self.appState.tapCount)")
          }.frame(width: 200, height: 200)
      }
  }
  </code></pre>
  
  <p><strong>ContentView.swift</strong></p>
  
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      var body: some View {
          HStack {
              LeftView()
              RightView()
          }.frame(width: 300, height: 200)
      }
  }
  </code></pre>
  
  <p>Unfortunately, the RightView text does not update with the tap count. However, if I use a timer in the ObservableObject class to update the tap count, then the RightView updates correctly.</p>
  
  <pre><code>import Foundation
  
  class AppState: ObservableObject {
      @Published var tapCount: Int = 0
  
      init() {
          Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
              self.tapCount += 1
          }
      }
  
      func incrementTapCount() {
          self.tapCount += 1
          print("tap count \(self.tapCount)")
      }
  }
  </code></pre>
  
  <p>Why does the tap gesture in LeftView not update the RightView text?</p>