McFamous

Untitled

Dec 24th, 2024
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import Foundation
  2. import Combine
  3.  
  4. class LoginViewModel {
  5. private let repository: AuthRepository
  6. private var cancellables = Set<AnyCancellable>()
  7.  
  8.  
  9. init(repository: AuthRepository) {
  10. self.repository = repository
  11. }
  12.  
  13. func initiateAuthSession(with number: String) {
  14. let apiFormatNumber = "RU#" + number.replacingOccurrences(of: " ", with: "")
  15. repository.initiateAuthSession(with: apiFormatNumber)
  16. .sink { [weak self] completion in
  17. guard case .failure(let errorType) = completion else { return }
  18. // send error to view
  19. } receiveValue: { [weak self] authSessionData in
  20. // send success to view self.view.success blah blah
  21. }
  22. .store(in: &cancellables)
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment