title: SwiftUI observe published object of published object
body: <p>When hitting the button, a player is added to the game and I want to observe the changes in the game through the view model. When I hit the button, the counter doesn't change.</p>
  <p>It's almost as if I need the game within the <code>ContentViewModel</code> to be both <code>@ObservedObject</code> and <code>@Published</code>.</p>
  <p>Can someone help me understand the fundamentals of why this is setup wrong and how I can fix it?</p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  import Combine
  
  class Game: ObservableObject {
      @Published var players: [String] = []
  
      func addPlayer(_ player: String) {
          players.append(player)
      }
  }
  
  class ContentViewModel: ObservableObject {
      @Published var game: Game {
          didSet {
              subscription = game.objectWillChange.sink { [weak self] _ in
                  self?.objectWillChange.send()
              }
          }
      }
      var subscription: AnyCancellable?
  
      init(game: Game) {
          self.game = game
      }
  }
  
  struct ContentView: View {
      @ObservedObject var viewModel: ContentViewModel
  
      var body: some View {
          Text(&quot;Num players: \(viewModel.game.players.count)&quot;)
              .padding()
  
          Button(&quot;Add player&quot;) {
              viewModel.game.addPlayer(&quot;player&quot;)
          }
      }
  }
  </code></pre>