无法在表视图委托cellForRowAt中执行publishSubject.onNext

时间:2019-12-23 11:34:07

标签: rx-swift rx-cocoa

    var notificationIDPublisher = PublishSubject<Void>()

    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let model = notificationItems[indexPath.row]
        let cell: NotificationCell = tableView.dequeueReusableCell(for: indexPath)
        readID = model.id

        notificationIDPublisher.onNext(())

        cell.readIndicatorImageView.isHidden = boolvalue
        cell.configure(with: model)
        return cell
    }



     fileprivate func bindCellEvents() {
        let unreadNotificationsss = notificationIDPublisher.asDriver(onErrorDriveWith: .empty())
        viewModel.bindCellEvents(readNotificationID: readnotificationID, unreadView: unreadNotificationsss)
    }

我希望notificationIDPublisher.onNext(())自动调用unreadNotificationsss,它在tableView委托内部不起作用,但是当我在tableView外部调用它时,我能够实现这一点。

0 个答案:

没有答案