-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
binding view with view model #2
Comments
[1차] viewModel.subject
.bind(to: tableView.rx.items(
cellIdentifier: "Cell",
cellType: UITableViewCell.self)) { index, item, cell in
cell.textLabel?.text = item.detailHash
}.disposed(by: disposeBag) [2차] private let dataSource = RxTableViewSectionedReloadDataSource<SectionOfData>(
configureCell: { (_, tableView, indexPath, element) in
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
cell.textLabel?.text = element.title
return cell
},
titleForHeaderInSection: { dataSource, sectionIndex in
return dataSource[sectionIndex].header
}
) [3차] main, soup, side의 순서(section)를 보장하기 위해 enum Category: Int {
case main = 1
case soup
case side
}
private var sections: [SectionOfData] = [] {
didSet {
sections.sort { $0.category < $1.category }
}
} [4차] 전체 section 대신, 먼저 받아온 데이터(main, soup, side)만 reload 할 수 없을까? // in view model
var subject = PublishSubject<IndexSet>()
// in controller
viewModel.subject
.subscribe(onNext: { data in
DispatchQueue.main.sync {
self.tableView.reloadSections(data, with: .automatic)
}
})
.disposed(by: disposeBag) 회고
|
The text was updated successfully, but these errors were encountered: