title: how to publish the data of a network request using Combine framework and SwiftUI
body: <p>I'm developing an iOS app using swiftUI and Combine framework and also MVVM.
  I'm want to handle the login API request in a separate class called LoginService, which is used in the LoginViewModel.
  Now I want to know how should I publish and observe the attributes between view and ViewModel.
  I mean ViewModel is an ObservableObject and is being observed in the View, But since I'm handling the network request in a Service class how should LoginService notify LoginViewModel and LoginView that the data is received and the View should be updated?</p>
  
  <pre><code>import Foundation
  import Combine
  
  class LoginViewModel: ObservableObject {
  
      @Published var user = UserModel()
  
      @Published var LoginStatus: Bool = false
  
      @Published var LoginMessage: String = ""
  
      var service = LoginService()
  
      func Login(With email: String, And password: String) -&gt; Bool {
          service.validateLogin(email: email, password: password)
          return false
      }
  }
  
  </code></pre>
  
  <p>This is the Code for LoginViewModel.
  How should LoginService change the values for LoginStatus, LoginMessage and user when data is received from the server to notify the View?
  I'm saying this because as far as I know you can Observe the ObservableObjects only in the View(SwiftUI).</p>