RxSwift - UICollectionView 更新后不更新

RxSwift - UICollectionView does not update after updating

我有一个带有 2 个控制器的 UITabBarController。

  1. 在第一个VC用户有文章列表。用户可以将一些文章添加到收藏夹(领域数据库)
  2. 第二个VC它是一个带有领域查询的列表(最喜欢的文章)。 当创建了 2 个控制器时(用户点击它们),并且在第一个 VC 中将文章添加到收藏夹中,在第二个 collectionView 中不显示新项目。

我的最爱VC collectionView 绑定

 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)

和我最喜欢的 ViewModel,它从 db

进行查询
class FavouriteViewModel {
let articlesSubject: PublishSubject<[ArticleModel]> = PublishSubject()



func fetchDateFromDb(){
    print(Realm.Configuration.defaultConfiguration.fileURL!)
    let articleList = DatabaseManager.shared.getAllArticle().toArray()

    articlesSubject.onNext(articleList)
}}

问题:创建控制器后,他没有更新。我该如何更新它?

问题出在我的集合视图自定义布局上。 这是正确的答案