let officialAccountObservable : Observable<[SearchUser]> = SearchAPI.sharedAPI.suggestAccounts()
officialAccountObservable.bind(to: tableView.rx.items(cellIdentifier: "followcell", cellType: FollowCell.self)) {
(index, user , cell) in
if user.profileImagePath.isEmpty == false {
cell.profile.af_setImage(withURL: URL.init(string: user.profileImagePath)!)
}else {
cell.profile.image = UIImage.init(named: "icon_user_03")
}
cell.nickName.text = user.nickName
cell.follow.rx.tap
.debounce(0.3, scheduler: MainScheduler.instance)
.subscribe(onNext: {
[unowned self] in
cell.setFollow(user: user, completion: { (result) in
if(result == true){
}
})
}).addDisposableTo(self.disposeBag)
}.addDisposableTo(disposeBag)
func suggestAccounts() -> Observable<[SearchUser]> {
let uri = Constants.VyrlSearchURL.suggestUsers
return Observable.create { observer in
let request = Alamofire.request(uri, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: Constants.VyrlAPIConstants.getHeader()).responseArray { (response: DataResponse<[SearchUser]>) in
let value = response.result.value
observer.onNext(value!)
observer.onCompleted()
}
return Disposables.create(with: request.cancel)
}
}
I want to reload the table view in code (result == true)
For reload, OfficialAccountObservable must be received.
My code is all over and I wonder how I can update it in that state.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…