title: Is there a way to embed a Published var in one ObservableObject into another ObservableObject?
body: <p>I have a Auth store (an ObservableObject) which stores whether a user has authenticated into the application. I manage the auth store when the user logs in, essentially changing the authentication state from notAuthenticated to authenticated. I use the same state variable in a ViewModel another ObservableObject, which refers to the Auth store singleton object. I think there might be a simpler way to do this than sinking the variable and updating it on the ViewModel (like directly embedding the Auth variable in the ViewModel).</p>
  <p>This is a simplified code for the auth store model</p>
  <pre><code>class Auth: ObservableObject {
      
      static let shared = Auth()
  
      @Published var currentState: AuthState = .notAuthenticated
  
      enum AuthState {
          case notAuthenticated
          case authenticated
      }
  }
  </code></pre>
  <p>This is the simplified view model</p>
  <pre><code>class SampleViewModel: ObservableObject {
  
      @Published var authState = Auth.shared.currentState
  
      init() {
      
          Auth.shared.$currentState.sink { newAuthState in
               self.authState = newAuthState
          } // Is there any simple way in which I can skip sinking the publishr
      }
  }
  </code></pre>