title: Publisher inside a Publisher does not trigger SwiftUi re-render
body: <p>I made a &quot;State&quot; Object for my App in EnvironmentObject
  Like this:</p>
  <pre><code>class AppState: ObservableObject {
      @Published var counter = Counter()
  }
  </code></pre>
  <p>To add this to my App I use:</p>
  <pre><code>window.rootViewController = UIHostingController(rootView: contentView.environmentObject(state))
  </code></pre>
  <p>The counter is a background task</p>
  <pre><code>class Counter: ObservableObject {
      
      @Published var amount: Double
      
      var timer = Timer()
      
      init() {
          self.amount = 0.0
          self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(setCoords), userInfo: nil, repeats: true)
      }
      
      @objc private func setCoords() {
          DispatchQueue.main.async() { () -&gt; Void in
              self.amount = self.amount + 0.1
              print(self.amount)
          }
      }  
  }
  </code></pre>
  <p>And in my View I have:</p>
  <pre><code>struct ContentView: View {
  
      @EnvironmentObject var state: AppState
      @State var isVisible = true
      
      var body: some View {
          VStack {
              Button(action: {
                  self.isVisible.toggle()
              }) {
                 Text(&quot;Button&quot;)
              }
              if isVisible {
                  Text(state.counter.amount.description)
              }
          }
      }
  }
  </code></pre>
  <p>So basically, what I was hoping was that I see the counter in my UI update after every second. But the UI does not update. I see the print statement fire every second and if I trigger the UI update from the UI Button <code>self.isVisible.toggle()</code> then the counter will also update.</p>
  <p>How could I solve this problem without moving the counter into the View or implementing it in the state object?</p>