Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何筛选驱动程序<;[存储库]>;rxswift中的对象_Ios_Swift_Rx Swift - Fatal编程技术网

Ios 如何筛选驱动程序<;[存储库]>;rxswift中的对象

Ios 如何筛选驱动程序<;[存储库]>;rxswift中的对象,ios,swift,rx-swift,Ios,Swift,Rx Swift,如何根据所选范围索引筛选驱动程序 1.请尝试进一步澄清您的问题:-您的目标是什么?-你到底得到了什么错误?我有一系列模型作为驱动程序,我想根据一些规则过滤它们并返回驱动程序。1。请尝试进一步澄清您的问题:-您的目标是什么?-你到底得到了什么错误?我有一系列模型作为驱动程序,我想根据一些规则过滤它们并返回驱动程序。 struct SearchViewModel { lazy var rx_SearchResults: Driver<[Repository]> = self.fe

如何根据所选范围索引筛选驱动程序


1.请尝试进一步澄清您的问题:-您的目标是什么?-你到底得到了什么错误?我有一系列模型作为驱动程序,我想根据一些规则过滤它们并返回驱动程序。1。请尝试进一步澄清您的问题:-您的目标是什么?-你到底得到了什么错误?我有一系列模型作为驱动程序,我想根据一些规则过滤它们并返回驱动程序。
struct SearchViewModel {
    lazy var rx_SearchResults: Driver<[Repository]> = self.fetchSearchResults()
    lazy var rx_FilteredSearchResults: Driver<[Repository]> = self.filteredSearchResults()
    fileprivate var searchQuery: Observable<String>
    fileprivate var scopeIndex:  Observable<Int>
init( searchTextObservable: Observable<String>, changeInScopeIndex: Observable<Int>)
    {
        self.searchQuery = searchTextObservable
        self.scopeIndex = changeInScopeIndex

    }
fileprivate func fetchRepositories() -> Driver<[Repository]> {
        return repositoryName
            .subscribeOn(MainScheduler.instance) // Make sure we are on MainScheduler
            .do(onNext: { response in
                UIApplication.shared.isNetworkActivityIndicatorVisible = true
            })
            .observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
            .flatMapLatest { text in // .background thread, network request
                return RxAlamofire
                    .requestJSON(.get, "https://api.github.com/users/\(text)/repos")
                    .debug()
                    .catchError { error in
                        return Observable.never()
                    }
            }
            .observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
            .map { (response, json) -> [Repository] in // again back to .background, map objects
                if let repos = Mapper<Repository>().mapArray(JSONObject: json) {
                    return repos
                } else {
                    return []
                }
            }
            .observeOn(MainScheduler.instance) // switch to MainScheduler, UI updates
            .do(onNext: { response in
                UIApplication.shared.isNetworkActivityIndicatorVisible = false
            })
            .asDriver(onErrorJustReturn: []) // This also makes sure that we are on MainScheduler
    }

}
    **fileprivate  func filteredSearchResults() -> Driver<[FilesListSearchData]> {
        return scopeIndex
            .subscribeOn(MainScheduler.instance) // Make sure we are on MainScheduler
            .do(onNext: { response in
                UIApplication.shared.isNetworkActivityIndicatorVisible = true
            })
            .observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
            .map { index in // again back to .background, map objects
                return self.rx_SearchResults.asDriver()
            }
            .observeOn(MainScheduler.instance) // switch to MainScheduler, UI updates
            .do(onNext: { response in
                UIApplication.shared.isNetworkActivityIndicatorVisible = false
            })


}**
        UIApplication.shared.isNetworkActivityIndicatorVisible = false/true