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.
AFAIK, this is the standard way of doing this -
let source = PublishSubject<Observable<[SearchUser]>>()
let officialAccountObservable: Observable<[SearchUser]> = source.switchLatest()
source.onNext(suggestAccounts()) // every call will refresh your table
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With