I have a UITabBarController with 2 controllers.
My favouriteVC collectionView binding
private func setupBinds(){
self.favArticleCollectionView.register(UINib(nibName: "PreviewItemVCell", bundle: nil), forCellWithReuseIdentifier: PreviewItemVCell.identifier)
viewModel
.articlesSubject
.observeOn(MainScheduler.instance)
.bind(to:
self.favArticleCollectionView.rx.items(cellIdentifier: PreviewItemVCell.identifier, cellType: PreviewItemVCell.self)) { (item, article,cell) in
cell.article = article
}.disposed(by: disposeBag)
and my favouriteViewModel which make a query from db
class FavouriteViewModel {
let articlesSubject: PublishSubject<[ArticleModel]> = PublishSubject()
func fetchDateFromDb(){
print(Realm.Configuration.defaultConfiguration.fileURL!)
let articleList = DatabaseManager.shared.getAllArticle().toArray()
articlesSubject.onNext(articleList)
}}
Problem: When the controller has created, he does not update. How I can update it?
The problem was with my custom layout for collection view. It is the right answer enter link description here