title: Blinking symbol with didSet in SwiftUI
body: <p>This is synthesized from a much larger app. I'm trying to blink an SF symbol in SwiftUI by activating a timer in a property's didSet. A print statement inside timer prints the expected value but the view doesn't update.</p>
  <p>I'm using structs throughout my model data and am guessing this will have something to do with value vs. reference types. I'm trying to avoid converting from structs to classes.</p>
  <pre><code>import SwiftUI
  import Combine
  
  @main
  struct TestBlinkApp: App {
    var body: some Scene {
      WindowGroup {
        ContentView()
      }
    }
  }
  
  class Model: ObservableObject {
    @Published var items: [Item] = []
    
    static var loadData: Model {
      let model = Model()
      model.items = [Item(&quot;Item1&quot;), Item(&quot;Item2&quot;), Item(&quot;Item3&quot;), Item(&quot;Item4&quot;)]
      
      return model
    }
  }
  
  struct Item {
    static let ledBlinkTimer: TimeInterval = 0.5
    
    private let ledTimer = Timer.publish(every: ledBlinkTimer, tolerance: ledBlinkTimer * 0.1, on: .main, in: .default).autoconnect()
    
    private var timerSubscription: AnyCancellable? = nil
    
    var name: String
    
    var isLEDon = false
    
    var isLedBlinking = false {
      didSet {
        var result = self
        print(&quot;in didSet: isLedBlinking: \(result.isLedBlinking) isLEDon: \(result.isLEDon)&quot;)
        guard result.isLedBlinking else {
          result.isLEDon = true
          result.ledTimer.upstream.connect().cancel()
          print(&quot;Cancelling timer.&quot;)
          return
        }
        result.timerSubscription = result.ledTimer
          .sink {  _ in
            result.isLEDon.toggle()
            print(&quot;\(result.name) in ledTimer isLEDon: \(result.isLEDon)&quot;)
          }
      }
    }
    
    init(_ name: String) {
      self.name = name
    }
  }
  
  
  struct ContentView: View {
    @StateObject var model = Model.loadData
    
    let color = Color(UIColor.label)
    
    public var body: some View {
      VStack {
        Text(model.items[0].name)
        Image(systemName: model.items[0].isLEDon ? &quot;circle.fill&quot; : &quot;circle&quot;)
          .foregroundColor(model.items[0].isLEDon ? .green : color)
        Button(&quot;Toggle&quot;) {
          model.items[0].isLedBlinking.toggle()
        }
      }
      .foregroundColor(color)
    }
  }
  </code></pre>
  <p>Touching the &quot;Toggle&quot; button starts the timer that's suppose to blink the circle. The print statement shows the value changing but the view doesn't update. Why??</p>