title: SwiftUI DispatchQueue Button
body: <p>I don't understand the issues around how SwiftUI and DispatchQueues work. Here is the code. </p>
  
  <p>This works and will continue to refresh the counter state variable every second.</p>
  
  <pre><code>// Example 1 - This works
  struct TimerButtonTest : View {
      @State var counter: Int = 0
      var body: some View {        
          start()
          return VStack { Text("\(counter)") }
      }
  
      func start() {
          DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1000)) {
              self.counter += 1
          }
      }
  }
  </code></pre>
  
  <p>This does not. After the button is pressed, the counter increments by 1 (after 1 second) but stops. </p>
  
  <pre><code>// Example 2 - This does not work
  struct TimerButtonTest : View {
      @State var counter: Int = 0
      var body: some View {
          return Button(action: {self.start()}, label: {Text("\(counter)")})
      }
  
      func start() {
          DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1000)) {
              self.counter += 1
          }
      }
  }
  </code></pre>
  
  <p>Why doesn't the counter continue incrementing like the first example? </p>