Slide 19
Slide 19 text
view_model.swift.liquid
final class {{ module_info.name }}ViewModelImpl: {{ module_info.name }}ViewModel {
let disposeBag = DisposeBag()
// output
let isLoading: Driver
let hasError: Driver
let toastMessage: Driver
// input
init(model: {{ module_info.name }}Model,
wireframe: {{ module_info.name }}Wireframe,
scheduler: SchedulerService = MainSchedulerService.shared) {
self.isLoading = model.isLoading
.asDriver(onErrorDriveWith: Driver.empty())
self.hasError = model.errors
.map({ $0.isError })
.asDriver(onErrorDriveWith: Driver.empty())
self.toastMessage = model.errors
.map({ $0.description })
.filterNil()
.asDriver(onErrorDriveWith: Driver.empty())
}
}