title: Push View programmatically in callback, SwiftUI
body: <p>It seems to me that Apple is encouraging us to give up using <code>UIViewController</code> in SwiftUI, but without using view controllers, I feel a little bit powerless. What I would like is to be able to implement some sort of <code>ViewModel</code> which will emit events to <code>View</code>.</p>
  <p><strong>ViewModel</strong>:</p>
  <pre><code>public protocol LoginViewModel: ViewModel {
    var onError: PassthroughSubject&lt;Error, Never&gt; { get }
    var onSuccessLogin: PassthroughSubject&lt;Void, Never&gt; { get }
  }
  </code></pre>
  <p><strong>View</strong>:</p>
  <pre><code>public struct LoginView: View {
    fileprivate let viewModel: LoginViewModel
    
    public init(viewModel: LoginViewModel) {
      self.viewModel = viewModel
    }
    
    public var body: some View {
      NavigationView {
        MasterView()
          .onReceive(self.viewModel.onError, perform: self.handleError)
          .onReceive(self.viewModel.onSuccessLogin, perform: self.handleSuccessfullLogin)
      }
    }
  
    func handleSuccessfullLogin() {
      //push next screen
    }
    
    func handleError(_ error: Error) {
      //show alert
    }
  }
  </code></pre>
  <p>Using SwiftUI, I don't know how to push another controller if login is successful</p>
  <p>Also, I would appreciate any advice about how to implement what I want in a better way. Thanks.</p>