//
|
// SwitchCityViewModel.swift
|
// OKProject
|
//
|
// Created by alvin_y on 2020/5/28.
|
// Copyright © 2020 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
import RxSwift
|
import RxCocoa
|
import HandyJSON
|
|
class SwitchCityViewModel: YYViewModel {
|
|
/// 城市列表
|
let cities = BehaviorRelay<[SwitchCitySection]>(value: [])
|
|
/// 获取开通城市
|
func queryOpenCity() {
|
requestSubject.onNext(.loading)
|
APIManager.shared.provider.rx
|
.request(.queryOpenCity)
|
.map(YYModel<[SwitchCityModel]>.self)
|
.validate()
|
.subscribe(onSuccess: { [weak self] (model) in
|
self?.requestSubject.onNext(.success(model.data))
|
}) { (error) in
|
self.requestSubject.onNext(.error(error))
|
}
|
.disposed(by: disposeBag)
|
}
|
}
|