From 71efeda55fb95d258c2d7a50b11967931b71ce57 Mon Sep 17 00:00:00 2001 From: jangseoyoung Date: Tue, 30 Nov 2021 16:55:50 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20MyPageViewModel?= =?UTF-8?q?=EC=97=90=20updatePassword=20=EA=B4=80=EB=A0=A8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/MyPage/MyPageViewModel.swift | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Sources/ViewModel/MyPage/MyPageViewModel.swift b/Sources/ViewModel/MyPage/MyPageViewModel.swift index 1ffebd7..b2c0122 100644 --- a/Sources/ViewModel/MyPage/MyPageViewModel.swift +++ b/Sources/ViewModel/MyPage/MyPageViewModel.swift @@ -9,7 +9,6 @@ import Foundation import RxSwift import RxCocoa -import KeychainSwift class MyPageViewModel: ViewModel { @@ -17,22 +16,25 @@ class MyPageViewModel: ViewModel { let output = Output() struct Input { - let logOutButtonIsTapped: Driver - let notificationSwitchIsOn: Driver + var confirmButtonIsTapped: Driver } struct Output { - var logOutResult = PublishRelay() + var changePasswordResult = PublishRelay() } func transform(_ input: Input) -> Output { - input.logOutButtonIsTapped.asObservable() - .subscribe( - onNext: { - KeychainSwift().delete("ACCESS-TOKEN") - } - ).disposed(by: disposeBag) - + input.confirmButtonIsTapped.asObservable().subscribe(onNext: { pwd in + HTTPClient.shared.networking( + api: .updatePassword(pwd), + model: EmptyModel.self + ).subscribe(onSuccess: { _ in + self.output.changePasswordResult.accept(true) + }, onFailure: { error in + print(error) + self.output.changePasswordResult.accept(false) + }).disposed(by: self.disposeBag) + }).disposed(by: disposeBag) return output } }