i try like this
class Model<T: TargetType>: NSObject {
func request<H: HandyJSON>(_ type: T, _ model: H.Type) -> Observable<H> {
let mp = MoyaProvider<T>()
return mp
.rx.request(type)
.asObservable()
.map(model)
}
}
class FirstViewModel: BaseViewModel<API> {
override func initialize() {
}
}
BaseViewModel has a instance of Model
then i call it.
let vm = (self.viewModel as! FirstViewModel)
vm
.model
.request(.Show, FirstModel.self)
.bind { (model) in
print(model)
}
.disposed(by: self.rx.disposeBag)
but it didn't work.
you're disposing your provider. Check out the documentation at https://github.com/Moya/Moya/pull/1386
It works as usual!
@AndrewSB thanks
Most helpful comment
you're disposing your provider. Check out the documentation at https://github.com/Moya/Moya/pull/1386