title: How to detect what changed a @Published value in SwiftUI?
body: <p>I have an <code>ObservableObject</code> with a <code>@Published</code> value, how can I detect if the value was changed via <code>TextField</code> view or it was set directly (When <code>Button</code> is tapped for instance)?</p>
  
  <pre><code>struct ContentView: View {
  
      @ObservedObject var model = Model()
  
      var body: some View {
          VStack {
              Button("set value") {
                  self.model.value = "user set value"
              }
              TextField("value", text: $model.value)
          }
      }
  }
  
  class Model: ObservableObject {
  
       @Published var value = ""
  
       var anyCancellable: AnyCancellable?
  
        init() {
            anyCancellable = $value.sink { val in
                // if changed by Button then ...
                // if changed by TextField then ...
            }
        }
  }
  </code></pre>
  
  <p>My real case scenario sounds like this: when the user changes the value a request have to be sent to the server with the new value, but the server can also respond with a new value (in that case a new request to server should not be sent), so I have to distinguish between the case when the user changes the value (via TextField) and the case when the server changes the value.</p>