You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
//
|
|
// DetailNotificationPresenter.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon James Kim on 2020/02/11.
|
|
//Copyright © 2020 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import RxSwift
|
|
import RxCocoa
|
|
|
|
class DetailNotificationPresenter: ViewModelType {
|
|
var interactor: DetailNotificationInteractorInput?
|
|
var wireframe: DetailNotificationWireframeInput?
|
|
|
|
struct Input {
|
|
let viewWillAppear: Driver<Void>
|
|
}
|
|
|
|
struct Output {
|
|
let isError: Driver<Error>
|
|
let isProgress: Driver<Bool>
|
|
let model: Driver<DetailNoticeModel>
|
|
}
|
|
|
|
private let disposeBag = DisposeBag()
|
|
|
|
private let progressLinker = PublishSubject<Bool>()
|
|
private let errorLinker = PublishSubject<Error>()
|
|
private let model = PublishSubject<DetailNoticeModel>()
|
|
|
|
private var index = ""
|
|
|
|
init(index: String) {
|
|
self.index = index
|
|
}
|
|
|
|
func transform(input: Input) -> Output {
|
|
input.viewWillAppear.drive(onNext: {[weak self] in
|
|
guard let `self` = self else { return }
|
|
self.progressLinker.onNext(true)
|
|
self.interactor?.fetchDetail(self.index)
|
|
}).disposed(by: disposeBag)
|
|
|
|
return Output(
|
|
isError: errorLinker.asDriverOnErrorJustComplete(),
|
|
isProgress: progressLinker.asDriverOnErrorJustComplete(),
|
|
model: model.asDriverOnErrorJustComplete()
|
|
)
|
|
}
|
|
}
|
|
|
|
// MARK: DetailNotification interactor output interface
|
|
extension DetailNotificationPresenter: DetailNotificationInteractorOutput {
|
|
func setModel(with model: DetailNoticeModel) {
|
|
progressLinker.onNext(false)
|
|
self.model.onNext(model)
|
|
}
|
|
|
|
func setError(with error: Error) {
|
|
progressLinker.onNext(false)
|
|
errorLinker.onNext(error)
|
|
}
|
|
}
|