I have a UITabBarController with 2 controllers.
- In the first VC user have a list of articles. A user can add some article to favourite (realm database)
- The second VC it is a list with realm query (favourite article). When 2 controllers created (user tap to both of them), and in the first VC add article to favourite in the second collectionView does not show new item.
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?