feat: 定义仓库协议与用例(含会话)
This commit is contained in:
24
IosClientKit/Sources/CoreDomain/SessionUseCase.swift
Normal file
24
IosClientKit/Sources/CoreDomain/SessionUseCase.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
/// 会话用例。
|
||||
public struct SessionUseCase: Sendable {
|
||||
private let repository: SessionRepository
|
||||
|
||||
public init(repository: SessionRepository) {
|
||||
self.repository = repository
|
||||
}
|
||||
|
||||
public func observeIsLoggedIn() -> AsyncThrowingStream<Bool, Error> {
|
||||
repository.observeIsLoggedIn()
|
||||
}
|
||||
|
||||
public func requestSmsCode(phone: String) async throws {
|
||||
try await repository.requestSmsCode(phone: phone)
|
||||
}
|
||||
|
||||
public func login(phone: String, code: String) async throws {
|
||||
try await repository.login(phone: phone, code: code)
|
||||
}
|
||||
|
||||
public func logout() async throws {
|
||||
try await repository.logout()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user