Skip to content

Commit

Permalink
⚡️ :: MyPageViewModel에 updatePassword 관련 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jangseoyoung committed Nov 30, 2021
1 parent 758dfec commit 71efeda
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Sources/ViewModel/MyPage/MyPageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,32 @@
import Foundation
import RxSwift
import RxCocoa
import KeychainSwift

class MyPageViewModel: ViewModel {

let disposeBag = DisposeBag()
let output = Output()

struct Input {
let logOutButtonIsTapped: Driver<Void>
let notificationSwitchIsOn: Driver<Void>
var confirmButtonIsTapped: Driver<String>
}

struct Output {
var logOutResult = PublishRelay<Bool>()
var changePasswordResult = PublishRelay<Bool>()
}

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
}
}

0 comments on commit 71efeda

Please sign in to comment.