Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- import Combine
- class LoginViewModel {
- private let repository: AuthRepository
- private var cancellables = Set<AnyCancellable>()
- init(repository: AuthRepository) {
- self.repository = repository
- }
- func initiateAuthSession(with number: String) {
- let apiFormatNumber = "RU#" + number.replacingOccurrences(of: " ", with: "")
- repository.initiateAuthSession(with: apiFormatNumber)
- .sink { [weak self] completion in
- guard case .failure(let errorType) = completion else { return }
- // send error to view
- } receiveValue: { [weak self] authSessionData in
- // send success to view self.view.success blah blah
- }
- .store(in: &cancellables)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment