Ios 合并:在func中将一个发布服务器转换为另一个发布服务器

Ios 合并:在func中将一个发布服务器转换为另一个发布服务器,ios,swift,combine,Ios,Swift,Combine,我正在联合框架上为我的auth使用放大框架 我想检查用户当前是否已登录。这是通过以下函数完成的 Amplify.Auth.fetchAuthSession() 这将返回: AnyPublisher<AuthSession,AuthError> enum AuthenticationsFunctions { static func fetchCurrentAuthSession() -> AnyPublisher<AuthSession, AuthError&g

我正在联合框架上为我的auth使用放大框架

我想检查用户当前是否已登录。这是通过以下函数完成的

Amplify.Auth.fetchAuthSession()
这将返回:

AnyPublisher<AuthSession,AuthError>
enum AuthenticationsFunctions {
    static func fetchCurrentAuthSession() -> AnyPublisher<AuthSession, AuthError> {
        Amplify.Auth.fetchAuthSession().resultPublisher
    }
}
    static func fetchCurrentLogin() -> Feedback<State, Event> {
    Feedback { (state: State) -> AnyPublisher<Event, Never> in
        guard case .loading = state else { return Empty().eraseToAnyPublisher() } //Checks if the state is loading (When the app first opens)
        AuthenticationsFunctions.fetchCurrentAuthSession().allSatisfy { (AuthSession) -> Bool in
            if (AuthSession.isSignedIn) {
                return true
            }
            else {
                return false
            }
        }
    }
}
func fetchCurrentAuthSession() -> AnyCancellable {
    Amplify.Auth.fetchAuthSession().resultPublisher
        .eraseToAnyPublisher()
        .sink {
            if case let .failure(authError) = $0 {
                print("Fetch session failed with error \(authError)")
            }
        }
        receiveValue: { session in
            print("Is user signed in - \(session.isSignedIn)")
        }
}