title: Combine @Published property: get current value during update, from elsewhere
body: <p>My main problem is that I'm trying to work around the (undocumented) fact that <code>@Published</code> properties don't update the property's value until after subscribers have been notified of the change. I can't seem to get a good way around it.</p>
  
  <p><strong>Consider the following contrived combination of a <code>Subject</code> and <code>@Published</code> properties. First, a simple class:</strong></p>
  
  <pre><code>class StringPager {
      @Published var page = 1
      @Published var string = ""
  }
  let pager = StringPager()
  </code></pre>
  
  <p><strong>And then a simple passthrough subject:</strong></p>
  
  <pre><code>let stringSubject = PassthroughSubject&lt;String, Never&gt;()
  </code></pre>
  
  <p>For debugging, let's subscribe to the string property and print it out:</p>
  
  <pre><code>pager.$string.sink { print($0) }
  </code></pre>
  
  <p>So far so good. Next, let's subscribe to the subject and alter the pager based on its value:</p>
  
  <pre><code>stringSubject.sink { string in
    if pager.page == 1 {
      pager.string = string
    } else {
      pager.string = string.uppercased()
    }
  }
  </code></pre>
  
  <p>Hopefully, this logic will allow us to make the pager string uppercased whenever we're not on the first page.</p>
  
  <p><strong>Now let's send values through the stringSubject when the page gets updated:</strong></p>
  
  <pre><code>pager.$page.sink { 
    $0 == 1 ? stringSubject.send("lowercase") : stringSubject.send("uppercase") 
  }
  </code></pre>
  
  <p>If we've gotten this logic right, then lowercase will always be lowercased, while uppercase will always be uppercased. Unfortunately, that's not at all what happens. Here's a sample output:</p>
  
  <pre><code>pager.page = 1 // lowercase
  pager.page = 2 // uppercase
  pager.page = 3 // UPPERCASE
  pager.page = 4 // UPPERCASE
  pager.page = 1 // LOWERCASE
  pager.page = 1 // lowercase
  </code></pre>
  
  <p>The reason for this is when we subscribe to the subject, we check the value of <code>pager.page</code>... but updating <code>pager.page</code> is what triggers the subject's closure, so the <code>pager.page</code> doesn't have an updated value yet, so the subject executes the wrong branch.</p>
  
  <p><strong>I've tried fixing this by both <code>zip</code>ing the <code>pager.$page</code> with the subject before sinking:</strong></p>
  
  <pre><code>stringSubject.zip(pager.$page).eraseToAnyPublisher().sink { ...same code... }
  </code></pre>
  
  <p>as well as <code>combineLatest</code>ing it:</p>
  
  <pre><code>stringSubject.combineLatest(pager.$page).eraseToAnyPublisher().sink { ...same code... }
  </code></pre>
  
  <p>but that leads either to the exact same observed behavior (in the former case) or equally undesired behavior except more of it (in the latter case).</p>
  
  <p><strong>How can I get the <em>current</em> page <em>within</em> the subject <code>sink</code> closure?</strong></p>