title: Create a Timer Publisher using Swift Combine
body: <p>I've been watching the <a href="https://developer.apple.com/videos/play/wwdc2019/226/" rel="noreferrer">Data Flow Through SwiftUI WWDC talk</a>. They have a slide with a sample code where they use a Timer publisher that gets connected to a SwiftUI View, and updates the UI with the time.</p>
  
  <p>I'm working on some code where I want to do the exact same thing, but can't figure out how this <code>PodcastPlayer.currentTimePublisher</code> is implemented, and then hooked to the UI struct. I have also watched all the videos about Combine.</p>
  
  <p>How can I achieve this?</p>
  
  <p>The sample code:</p>
  
  <pre><code>struct PlayerView : View {
    let episode: Episode
    @State private var isPlaying: Bool = true
    @State private var currentTime: TimeInterval = 0.0
  
    var body: some View {
      VStack { // ...
        Text("\(playhead, formatter: currentTimeFormatter)")
      }
      .onReceive(PodcastPlayer.currentTimePublisher) { newCurrentTime in
        self.currentTime = newCurrentTime
      }
    }
  }
  </code></pre>