I have an array of numbers, and I want the tableview to show the number(s) that I entered in searchbar. This is my code, I don't know what shall I write in the line after (instead of) .subscribe
let dataSource = BehaviorRelay(value: [String]())
let disposeBag = DisposeBag()
var numbers = ["1", "2", "3", "4", "5"]
override func viewDidLoad() {
super.viewDidLoad()
dataSource.accept(numbers)
searchBar.rx.text.orEmpty
.throttle(.milliseconds(2000), scheduler: MainScheduler.instance)
.filter{self.numbers.contains($0)}
.subscribe(onNext:
})
self.dataSource
.asObservable()
.bind(to: tableView.rx.items(cellIdentifier: "Cell", cellType: TableViewCell.self)) {(row, element, cell) in
cell.textLabel?.text = element
}
.disposed(by: disposeBag)
Maybe it doesn't work because of other reasons, anyway thank you for help